Upgrade Vim version to 7.4

按照官網的說明 (連結),升級vim版本有點簡單
不過可以先檢查vim的版本,以免做白工了

[root@WP ~]# vim --version
VIM - Vi IMproved 7.2 (2008 Aug 9, compiled Apr  5 2012 10:12:47)
引入修正: 1-411
修改者為
編譯者:
超強版本 不使用圖型界面。
 目前可使用(+)與不可使用(-)的模組列表:
+arabic +autocmd -balloon_eval -browse ++builtin_terms +byte_offset +cindent
-clientserver -clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments
+cryptv +cscope +cursorshape +dialog_con +diff +digraphs -dnd -ebcdic
+emacs_tags +eval +ex_extra +extra_search +farsi +file_in_path +find_in_path
+float +folding -footer +fork() +gettext -hangul_input +iconv +insert_expand
+jumplist +keymap +langmap +libcall +linebreak +lispindent +listcmds +localmap
+menu +mksession +modify_fname +mouse -mouseshape +mouse_dec +mouse_gpm
-mouse_jsbterm +mouse_netterm -mouse_sysmouse +mouse_xterm +multi_byte
+multi_lang -mzscheme -netbeans_intg -osfiletype +path_extra +perl +postscript
+printer +profile +python +quickfix +reltime +rightleft -ruby +scrollbind
+signs +smartindent -sniff +startuptime +statusline -sun_workshop +syntax
+tag_binary +tag_old_static -tag_any_white -tcl +terminfo +termresponse
+textobjects +title -toolbar +user_commands +vertsplit +virtualedit +visual
+visualextra +viminfo +vreplace +wildignore +wildmenu +windows +writebackup
-X11 -xfontset -xim -xsmp -xterm_clipboard -xterm_save
        系統 vimrc 設定檔: "/etc/vimrc"
  使用者個人 vimrc 設定檔: "$HOME/.vimrc"
   使用者個人 exrc 設定檔: "$HOME/.exrc"
              $VIM 預設值: "/usr/share/vim"
編譯方式: gcc -c -I. -Iproto -DHAVE_CONFIG_H     -O2 -g -pipe -Wall  -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64  -D_FORTIFY_SOURCE=1    -D_REENTRANT -D_GNU_SOURCE  -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64  -I/usr/lib/perl5/CORE  -I/usr/include/python2.6 -pthread
鏈結方式: gcc   -Wl,-E -Wl,-rpath,/usr/lib/perl5/CORE   -L/usr/local/lib -o vim       -lselinux  -lncurses -lacl -lgpm   -Wl,-E -Wl,-rpath,/usr/lib/perl5/CORE  -fstack-protector -L/usr/local/lib  -L/usr/lib/perl5/CORE -lperl -lresolv -lutil -lc -L/usr/lib/python2.6/config -lpython2.6 -lutil -lm -Xlinker -export-dynamic

這邊可以看到目前安裝版本為7.2
來先把舊版移除掉

[root@WP src]# yum erase vim
Loaded plugins: fastestmirror
Setting up Remove Process
Resolving Dependencies
--> Running transaction check
---> Package vim-enhanced.i686 2:7.2.411-1.8.el6 will be erased
--> Finished Dependency Resolution

Dependencies Resolved

===================================================================================================================================================
 Package                              Arch                         Version                                     Repository                     Size
===================================================================================================================================================
Removing:
 vim-enhanced                         i686                         2:7.2.411-1.8.el6                           @base                         1.8 M

Transaction Summary
===================================================================================================================================================
Remove        1 Package(s)

Installed size: 1.8 M
Is this ok [y/N]:y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Erasing    : 2:vim-enhanced-7.2.411-1.8.el6.i686                                                                                             1/1
  Verifying  : 2:vim-enhanced-7.2.411-1.8.el6.i686                                                                                             1/1

Removed:
  vim-enhanced.i686 2:7.2.411-1.8.el6

Complete!

接著就來照著官網說明升級到7.4吧~~

[root@WP ~]# hg clone https://vim.googlecode.com/hg/ vim
-bash: hg:命令找不到

可以得知缺少Mercuial套件,使用yum進行安裝

[root@WP ~]# yum install hg
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: ftp.twaren.net
 * epel: mirror01.idc.hinet.net
 * extras: ftp.twaren.net
 * rpmforge: ftp.kddilabs.jp
 * updates: ftp.twaren.net
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package mercurial.i686 0:1.4-3.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=======================================================================================================================================
 Package                           Arch                         Version                             Repository                    Size
=======================================================================================================================================
Installing:
 mercurial                         i686                         1.4-3.el6                           base                         1.5 M

Transaction Summary
=======================================================================================================================================
Install       1 Package(s)

Total download size: 1.5 M
Installed size: 7.0 M
Is this ok [y/N]: y
Downloading Packages:
mercurial-1.4-3.el6.i686.rpm                                                                                    | 1.5 MB     00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : mercurial-1.4-3.el6.i686                                                                                            1/1
  Verifying  : mercurial-1.4-3.el6.i686                                                                                            1/1

Installed:
  mercurial.i686 0:1.4-3.el6

Complete!

將Source檔案複製到vim資料夾內

[root@WP ~]# hg clone https://vim.googlecode.com/hg/ vim
requesting all changes
adding changesets
adding manifests
adding file changes
added 5695 changesets with 29802 changes to 2679 files (+2 heads)
updating to branch default
2497 files updated, 0 files merged, 0 files removed, 0 files unresolved

就到vim/src裡面進行make吧~

[root@WP ~]# cd vim/src
[root@WP src]# make

這時候發現還是少了東西…

checking for tgetent in -ltermcap... no
checking for tgetent in -lcurses... no
no terminal library found
checking for tgetent()... configure: error: NOT FOUND!
      You need to install a terminal library; for example ncurses.
      Or specify the name of the library with --with-tlib.
make[1]: *** [config] Error 1
make[1]: Leaving directory `/root/ycm_build/vim/src'
make: *** [first] Error 2

就來安裝ncurses-devel library

[root@WP src]# yum install ncurses-devel
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: ftp.twaren.net
 * epel: mirror01.idc.hinet.net
 * extras: ftp.twaren.net
 * rpmforge: ftp.kddilabs.jp
 * updates: ftp.twaren.net
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package ncurses-devel.i686 0:5.7-3.20090208.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=======================================================================================================================================
 Package                            Arch                      Version                                  Repository                 Size
=======================================================================================================================================
Installing:
 ncurses-devel                      i686                      5.7-3.20090208.el6                       base                      642 k

Transaction Summary
=======================================================================================================================================
Install       1 Package(s)

Total download size: 642 k
Installed size: 1.7 M
Is this ok [y/N]: y
Downloading Packages:
ncurses-devel-5.7-3.20090208.el6.i686.rpm                                                                       | 642 kB     00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : ncurses-devel-5.7-3.20090208.el6.i686                                                                               1/1
  Verifying  : ncurses-devel-5.7-3.20090208.el6.i686                                                                               1/1

Installed:
  ncurses-devel.i686 0:5.7-3.20090208.el6

Complete!

然後再跑一下make跑一下vim的編譯

##前略##
link.sh: Linked fine
cd xxd; CC="gcc" CFLAGS=" -O2 -fno-strength-reduce -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1" LDFLAGS="-L/usr/local/lib -Wl,--as-needed" 
                make -f Makefile
make[3]: Entering directory `/root/ycm_build/vim/src/xxd'
gcc  -O2 -fno-strength-reduce -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -L/usr/local/lib -Wl,--as-needed -DUNIX -o xxd xxd.c
make[3]: Leaving directory `/root/ycm_build/vim/src/xxd'
make[2]: Leaving directory `/root/ycm_build/vim/src'
make[1]: Leaving directory `/root/ycm_build/vim/src'

然後跑一下make install進行安裝

[root@WP src]# make install
##前略##
if test -n "" -a -f po/Makefile; then 
           cd po; make prefix=/usr/local LOCALEDIR=/usr/local/share/vim/vim74/lang 
           INSTALL_DATA=cp FILEMOD=644 install; 
        fi
if test -d ../runtime/lang; then 
           cp ../runtime/lang/README.txt ../runtime/lang/*.vim /usr/local/share/vim/vim74/lang; 
           chmod 644 /usr/local/share/vim/vim74/lang/README.txt /usr/local/share/vim/vim74/lang/*.vim; 
        fi
if test -d ../runtime/keymap; then 
           cp ../runtime/keymap/README.txt ../runtime/keymap/*.vim /usr/local/share/vim/vim74/keymap; 
           chmod 644 /usr/local/share/vim/vim74/keymap/README.txt /usr/local/share/vim/vim74/keymap/*.vim; 
        fi
if test -d /usr/local/share/icons/hicolor/48x48/apps -a -w /usr/local/share/icons/hicolor/48x48/apps 
                -a ! -f /usr/local/share/icons/hicolor/48x48/apps/gvim.png; then 
           cp ../runtime/vim48x48.png /usr/local/share/icons/hicolor/48x48/apps/gvim.png; 
        fi
if test -d /usr/local/share/icons/locolor/32x32/apps -a -w /usr/local/share/icons/locolor/32x32/apps 
                -a ! -f /usr/local/share/icons/locolor/32x32/apps/gvim.png; then 
           cp ../runtime/vim32x32.png /usr/local/share/icons/locolor/32x32/apps/gvim.png; 
        fi
if test -d /usr/local/share/icons/locolor/16x16/apps -a -w /usr/local/share/icons/locolor/16x16/apps 
                -a ! -f /usr/local/share/icons/locolor/16x16/apps/gvim.png; then 
           cp ../runtime/vim16x16.png /usr/local/share/icons/locolor/16x16/apps/gvim.png; 
        fi

這時候如果心急著想打vim會得到以下的結果….

[root@WP src]# vim
-bash: /usr/bin/vim: 沒有此一檔案或目錄

來把環境登錄變數重跑一下,就發現ok了!

[root@WP src]# hash -r
[root@WP src]# vim --version
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Feb 28 2014 02:15:51)
Included patches: 1-192
Compiled by cowman@WP
Normal version without GUI.  Features included (+) or not (-):
+acl             -farsi           -mouse_netterm   +syntax
-arabic          +file_in_path    -mouse_sgr       +tag_binary
+autocmd         +find_in_path    -mouse_sysmouse  +tag_old_static
-balloon_eval    +float           -mouse_urxvt     -tag_any_white
-browse          +folding         +mouse_xterm     -tcl
+builtin_terms   -footer          +multi_byte      +terminfo
+byte_offset     +fork()          +multi_lang      +termresponse
+cindent         -gettext         -mzscheme        +textobjects
-clientserver    -hangul_input    +netbeans_intg   +title
-clipboard       +iconv           +path_extra      -toolbar
+cmdline_compl   +insert_expand   -perl            +user_commands
+cmdline_hist    +jumplist        +persistent_undo +vertsplit
+cmdline_info    -keymap          +postscript      +virtualedit
+comments        -langmap         +printer         +visual
-conceal         +libcall         -profile         +visualextra
+cryptv          +linebreak       -python          +viminfo
-cscope          +lispindent      -python3         +vreplace
+cursorbind      +listcmds        +quickfix        +wildignore
+cursorshape     +localmap        +reltime         +wildmenu
+dialog_con      -lua             -rightleft       +windows
+diff            +menu            -ruby            +writebackup
+digraphs        +mksession       +scrollbind      -X11
-dnd             +modify_fname    +signs           -xfontset
-ebcdic          +mouse           +smartindent     -xim
-emacs_tags      -mouseshape      -sniff           -xsmp
+eval            -mouse_dec       +startuptime     -xterm_clipboard
+ex_extra        -mouse_gpm       +statusline      -xterm_save
+extra_search    -mouse_jsbterm   -sun_workshop    -xpm
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
  fall-back for $VIM: "/usr/local/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H     -O2 -fno-strength-reduce -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc   -L/usr/local/lib -Wl,--as-needed -o vim        -lm -ltinfo -lnsl  -lselinux
This entry was posted in Linux. Bookmark the permalink.