CentOS系统中安装高亮vim编辑工具的方法
人气:0们在安装完Centos后,它默认的是安装了VI编辑器,VIM是没有安装的,所以我们在使用vim test.txt时会提示: vim command not found 。。。 这就是说明我们的Linux环境没有安装vim编辑器,下面我们来说一下如何安装这个编辑器:
vim编辑器需要安装三个包:
vim-enhanced-7.0.109-7.el5
vim-minimal-7.0.109-7.el5
vim-common-7.0.109-7.el5
1. 查看一下你本机已经存在的包,确认一下你的VIM是否已经安装:
输入 rpm -qa|grep vim 这个命令,如何vim已经正确安装,则会显示上面三个包的名称
2. 如果缺少了其中某个,比如说: vim-enhanced这个包少了,执行:yum -y install vim-enhanced 命令,它会自动下载安装。
3. 如果上面三个包一个都没有显示,则直接输入命令:
yum -y install vim*
即可自动安装,完毕后,即可使用vim编辑器。
通常:我们选择VIM编辑器的原因是因为它可以提供一些很方便的利于我们工作的功能,我们可以把vim看作vi的变种,当然我们更多的是把vim当作一个代码的编译器,无论是C,还是Shell脚本,它均提供高亮显示,方便我们编写与检错。
通常:
设置vim编辑环境有两种形式:
一种是在/etc/vimrc进行设置,这种设置方法会作用与所有登录到Linux环境下的用户,一般情况下我们不提倡这种方式,因为Linux是多用户的,每个人都有自己的编程习惯与环境,因此我们提倡下面一种设置方式。
另一种:是在用户登录的~目录下创建一个 .vimrc文件,在其中进行自己习惯的编程环境的设置,这样当别的用户使用时并不相互影响。
具体方法:
cd ~
touch .vimrc
vim .vimrc
在文件中输入:
set nu // 这是设置显示行号
set showmode //设置在命令行界面最下面显示当前模式等。
set ruler // 在右下角显示光标所在的行数等信息
set autoindent // 设置每次单击Enter键后,光标移动到下一行时与上一行的起始字符对齐
syntax on // 即设置语法检测,当编辑C或者Shell脚本时,关键字会用特殊颜色显示
.........
[ESC]
wq
设置完成:运行结果例如:
CentOS 5.4 安装高亮vim编辑工具步骤很简单,Linux 高手请无视此篇,几行命令搞定 !!
[root@localhost ~]# yum install vim-*
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* addons: mirrors.ta139.com
* base: mirrors.ta139.com
* extras: mirrors.ta139.com
* updates: mirrors.ta139.com
addons | 1.9 kB 00:00
base | 1.1 kB 00:00
extras | 2.1 kB 00:00
updates | 1.9 kB 00:00
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package vim-X11.i386 2:7.0.109-7.2.el5 set to be updated
---> Package vim-common.i386 2:7.0.109-7.2.el5 set to be updated
---> Package vim-enhanced.i386 2:7.0.109-7.2.el5 set to be updated
---> Package vim-minimal.i386 2:7.0.109-7.2.el5 set to be updated
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
vim-X11 i386 2:7.0.109-7.2.el5 base 1.4 M
vim-common i386 2:7.0.109-7.2.el5 base 6.4 M
vim-enhanced i386 2:7.0.109-7.2.el5 base 1.2 M
Updating:
vim-minimal i386 2:7.0.109-7.2.el5 base 310 k
Transaction Summary
===============================================================================
Install 3 Package(s)
Update 1 Package(s)
Remove 0 Package(s)
Total download size: 9.4 M
Is this ok [y/N]: y
Downloading Packages:
(1/4): vim-minimal-7.0.109-7.2.el5.i386.rpm | 310 kB 00:00
(2/4): vim-enhanced-7.0.109-7.2.el5.i386.rpm | 1.2 MB 00:06
(3/4): vim-X11-7.0.109-7.2.el5.i386.rpm | 1.4 MB 00:09
(4/4): vim-common-7.0.109-7.2.el5.i386.rpm | 6.4 MB 00:56
-------------------------------------------------------------------------------
Total 130 kB/s | 9.4 MB 01:13
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : vim-common 1/5
Installing : vim-X11 2/5
Installing : vim-enhanced 3/5
Updating : vim-minimal 4/5
Cleanup : vim-minimal 5/5
Installed:
vim-X11.i386 2:7.0.109-7.2.el5 vim-common.i386 2:7.0.109-7.2.el5 vim-enhanced.i386 2:7.0.109-7.2.el5
Updated:
vim-minimal.i386 2:7.0.109-7.2.el5
Complete!
[root@localhost ~]# which vi
/bin/vi
[root@localhost ~]# which vim
/usr/bin/vim
[root@localhost ~]# rm /bin/vi
rm: remove regular file `/bin/vi'? y
[root@localhost ~]# ln -s /usr/bin/vim /bin/vi
[root@localhost ~]# which vi
/bin/vi
[root@localhost ~]# ls -l /bin/vi
lrwxrwxrwx 1 root root 12 Jan 18 01:22 /bin/vi -> /usr/bin/vim
如果需要更高深地需求,请直接修改/etc/vimrc 配置文件即可。
[root@localhost ~]# yum install vim-*
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* addons: mirrors.ta139.com
* base: mirrors.ta139.com
* extras: mirrors.ta139.com
* updates: mirrors.ta139.com
addons | 1.9 kB 00:00
base | 1.1 kB 00:00
extras | 2.1 kB 00:00
updates | 1.9 kB 00:00
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package vim-X11.i386 2:7.0.109-7.2.el5 set to be updated
---> Package vim-common.i386 2:7.0.109-7.2.el5 set to be updated
---> Package vim-enhanced.i386 2:7.0.109-7.2.el5 set to be updated
---> Package vim-minimal.i386 2:7.0.109-7.2.el5 set to be updated
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
vim-X11 i386 2:7.0.109-7.2.el5 base 1.4 M
vim-common i386 2:7.0.109-7.2.el5 base 6.4 M
vim-enhanced i386 2:7.0.109-7.2.el5 base 1.2 M
Updating:
vim-minimal i386 2:7.0.109-7.2.el5 base 310 k
Transaction Summary
===============================================================================
Install 3 Package(s)
Update 1 Package(s)
Remove 0 Package(s)
Total download size: 9.4 M
Is this ok [y/N]: y
Downloading Packages:
(1/4): vim-minimal-7.0.109-7.2.el5.i386.rpm | 310 kB 00:00
(2/4): vim-enhanced-7.0.109-7.2.el5.i386.rpm | 1.2 MB 00:06
(3/4): vim-X11-7.0.109-7.2.el5.i386.rpm | 1.4 MB 00:09
(4/4): vim-common-7.0.109-7.2.el5.i386.rpm | 6.4 MB 00:56
-------------------------------------------------------------------------------
Total 130 kB/s | 9.4 MB 01:13
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : vim-common 1/5
Installing : vim-X11 2/5
Installing : vim-enhanced 3/5
Updating : vim-minimal 4/5
Cleanup : vim-minimal 5/5
Installed:
vim-X11.i386 2:7.0.109-7.2.el5 vim-common.i386 2:7.0.109-7.2.el5 vim-enhanced.i386 2:7.0.109-7.2.el5
Updated:
vim-minimal.i386 2:7.0.109-7.2.el5
Complete!
[root@localhost ~]# which vi
/bin/vi
[root@localhost ~]# which vim
/usr/bin/vim
[root@localhost ~]# rm /bin/vi
rm: remove regular file `/bin/vi'? y
[root@localhost ~]# ln -s /usr/bin/vim /bin/vi
[root@localhost ~]# which vi
/bin/vi
[root@localhost ~]# ls -l /bin/vi
lrwxrwxrwx 1 root root 12 Jan 18 01:22 /bin/vi -> /usr/bin/vim
如果需要更高深地需求,请直接修改/etc/vimrc 配置文件即可。
加载全部内容