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脚本时,关键字会用特殊颜色显示