VMware下CentOS安裝成功後,默認自帶vi,但vi功能沒vim豐富。如下爲CentOS中安裝vim:html
用yum產看源中的vim安裝包:golang
[xi@localhost ~]$ yum search vim Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: ftp.jaist.ac.jp * extras: ftp.jaist.ac.jp * updates: ftp.jaist.ac.jp =============================== N/S matched: vim =============================== golang-vim.noarch : Vim plugins for Go protobuf-vim.x86_64 : Vim syntax highlighting for Google Protocol Buffers : descriptions vim-X11.x86_64 : The VIM version of the vi editor for the X Window System vim-common.x86_64 : The common files needed by any version of the VIM editor vim-enhanced.x86_64 : A version of the VIM editor which includes recent : enhancements vim-filesystem.x86_64 : VIM filesystem layout vim-minimal.x86_64 : A minimal version of the VIM editor Name and summary matches only, use "search all" for everything.
其中,vim編輯器須要安裝三個包:
編程
vim-enhanced-7.0.109-7.el5
vim-minimal-7.0.109-7.el5
vim-common-7.0.109-7.el5
1. 查看本機已存在的vim包,確認一下vim包是否已經安裝:vim
[xi@localhost ~]$ rpm -qa|grep vim vim-minimal-7.4.160-1.el7.x86_64 vim-filesystem-7.4.160-1.el7.x86_64 vim-common-7.4.160-1.el7.x86_64 vim-enhanced-7.4.160-1.el7.x86_64
2.若是未出現以上的安裝包,執行如下命令便可完成vim包的安裝:bash
$ yum -y install vim*
3.測試vim包是否安裝成功:編輯器
[xi@localhost ~]$ vim --version
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jun 10 2014 06:55:55)ide
--------------------------------------------------------------------------------------------------------------------------測試
P.S. vim編輯器環境配置:spa
是在用戶登陸的~目錄下建立一個 .vimrc文件,在其中進行本身習慣的編程環境的設置,這樣當別的用戶使用時並不相互影響。命令行
[xi@localhost ~]$ cd ~ [xi@localhost ~]$ ls Desktop Documents Downloads Music Pictures Public Templates Videos [xi@localhost ~]$ touch .vimrc [xi@localhost ~]$ vim .vimrc
在.vimr c文件中輸入如下內容:
set nu // 設置顯示行號 set showmode //設置在命令行界面最下面顯示當前模式等。 set ruler //設置在右下角顯示光標所在的行數等信息 set autoindent // 設置每次單擊Enter鍵後,光標移動到下一行時與上一行的起始字符對>齊 syntax on // 即設置語法檢測,當編輯C或者Shell腳本時,關鍵字會用特殊顏色顯示