用centos 的主機的時候, 用 vim 時出現 -bash: vim: command not found. 只能使用 vi. 那麼如何安裝 vim 呢?
輸入 rpm -qa|grep vim 命令, 如果 vim 已經正確安裝,會返回下面的三行代碼:
[root@centos]# rpm -qa |grep vim
vim-minimal-7.0.109-6.el5
vim-common-7.0.109-7.2.el5
vim-enhanced-7.0.109-7.2.el5
如果少了其中的某一條,比如 vim-enhanced 的,就用命令 yum -y install vim-enhanced 來安裝:
yum -y install vim-enhanced
如果上面的三條都沒有返回, 可以直接用 yum -y install vim* 命令
yum -y install vim*二。[root@localhost ~]# ll#部分省略了......-rwxr--r-- 1 root root 34 Apr 26 12:48 test.txt#用vim開啟test.txt檔案[root@localhost ~]# vim test.txt-bash: vim: command not found[root@localhost ~]##使用命令查詢[root@localhost ~]# rpm -qa | grep vimvim-minimal-7.0.109-6.el5#發現只有這個包,說明沒安裝完整,需要重新安裝vim#下面是安裝過程[root@localhost ~]# yum install -y vim*Loaded plugins: fastestmirrorLoading mirror speeds from cached hostfile* addons: mirrors.grandcloud.cn* base: mirrors.grandcloud.cn* extras: mirrors.grandcloud.cn* updates: mirrors.grandcloud.cnSetting up Install ProcessResolving Dependencies--> Running transaction check---> Package vim-X11.x86_64 2:7.0.109-7.2.el5 set to be updated---> Package vim-common.x86_64 2:7.0.109-7.2.el5 set to be updated---> Package vim-enhanced.x86_64 2:7.0.109-7.2.el5 set to be updated---> Package vim-minimal.x86_64 2:7.0.109-7.2.el5 set to be updated--> Finished Dependency ResolutionDependencies Resolved========================================================================================Package Arch Version Repository Size========================================================================================Installing:vim-X11 x86_64 2:7.0.109-7.2.el5 base 1.0 Mvim-common x86_64 2:7.0.109-7.2.el5 base 6.4 Mvim-enhanced x86_64 2:7.0.109-7.2.el5 base 1.3 MUpdating:vim-minimal x86_64 2:7.0.109-7.2.el5 base 334 kTransaction Summary========================================================================================Install 3 Package(s)Upgrade 1 Package(s)Total download size: 9.1 MDownloading Packages:(1/4): vim-minimal-7.0.109-7.2.el5.x86_64.rpm | 334 kB 00:00 (2/4): vim-X11-7.0.109-7.2.el5.x86_64.rpm | 1.0 MB 00:03 (3/4): vim-enhanced-7.0.109-7.2.el5.x86_64.rpm | 1.3 MB 00:03 (4/4): vim-common-7.0.109-7.2.el5.x86_64.rpm | 6.4 MB 00:21 ----------------------------------------------------------------------------------------Total 314 kB/s | 9.1 MB 00:29 Running rpm_check_debugRunning Transaction TestFinished Transaction TestTransaction Test SucceededRunning TransactionInstalling : vim-common 1/5Installing : vim-X11 2/5Updating : vim-minimal 3/5Installing : vim-enhanced 4/5Cleanup : vim-minimal 5/5Installed:vim-X11.x86_64 2:7.0.109-7.2.el5 vim-common.x86_64 2:7.0.109-7.2.el5 vim-enhanced.x86_64 2:7.0.109-7.2.el5 Updated:vim-minimal.x86_64 2:7.0.109-7.2.el5 Complete!#安裝成功[root@localhost ~]# [root@localhost ~]# vim test.txt#進入vim操作介面#:q退出介面後,使用命令查看[root@localhost ~]# rpm -qa | grep vimvim-enhanced-7.0.109-7.2.el5vim-common-7.0.109-7.2.el5vim-X11-7.0.109-7.2.el5vim-minimal-7.0.109-7.2.el5