安装虚拟机部署centos系统,使用vi编辑代码时,发现没有颜色区分,而自己其他机器是可以显示颜色的。通过查看其他主机的信息,发现vi 其实是vim。当我使用vim时无法找到该命令,查询安装信息如下
[root@linuxcentos7 ~]$ [root@linuxcentos7 ~]$ rpm -qa |grep vim vim-minimal-7.4.629-7.el7.x86_64 [root@linuxcentos7 ~]$ [root@linuxcentos7 ~]$ alias alias egrep='egrep --color=auto' alias fgrep='fgrep --color=auto' alias grep='grep --color=auto' alias l.='ls -d .* --color=auto' alias ll='ls -l --color=auto' alias ls='ls --color=auto' alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde' [root@linuxcentos7 ~]$
原因:vi是没有颜色的,其他机器上,在linux的控制台下用vi编辑文件却能看到彩色这是因为安装了vim-enhanced的包,所以我们运行vi实际上运行的是vi的增强版本vim;目前本虚拟机需要安装 vim-enhanced,安装后默认在控制台就是彩色显示了。
安装vim
[root@linuxcentos7 ~]# rpm -qa |grep vim vim-minimal-7.4.629-7.el7.x86_64 [root@linuxcentos7 ~]# [root@linuxcentos7 ~]# [root@linuxcentos7 ~]# yum install vim Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirror.lzu.edu.cn * extras: ftp.sjtu.edu.cn * updates: ftp.sjtu.edu.cn base | 3.6 kB 00:00:00 extras | 2.9 kB 00:00:00 updates | 2.9 kB 00:00:00 (1/2): updates/7/x86_64/primary_db | 17 MB 00:00:03 (2/2): extras/7/x86_64/primary_db | 250 kB 00:00:13 Resolving Dependencies --> Running transaction check ---> Package vim-enhanced.x86_64 2:7.4.629-8.el7_9 will be installed --> Processing Dependency: vim-common = 2:7.4.629-8.el7_9 for package: 2:vim-enhanced-7.4.629-8.el7_9.x86_64 --> Processing Dependency: libgpm.so.2()(64bit) for package: 2:vim-enhanced-7.4.629-8.el7_9.x86_64 --> Running transaction check ---> Package gpm-libs.x86_64 0:1.20.7-6.el7 will be installed ---> Package vim-common.x86_64 2:7.4.629-8.el7_9 will be installed --> Processing Dependency: vim-filesystem for package: 2:vim-common-7.4.629-8.el7_9.x86_64 --> Running transaction check ---> Package vim-filesystem.x86_64 2:7.4.629-8.el7_9 will be installed --> Finished Dependency Resolution Dependencies Resolved ======================================================================================================================== Package Arch Version Repository Size ======================================================================================================================== Installing: vim-enhanced x86_64 2:7.4.629-8.el7_9 updates 1.1 M Installing for dependencies: gpm-libs x86_64 1.20.7-6.el7 base 32 k vim-common x86_64 2:7.4.629-8.el7_9 updates 5.9 M vim-filesystem x86_64 2:7.4.629-8.el7_9 updates 11 k Transaction Summary ======================================================================================================================== Install 1 Package (+3 Dependent packages) Total download size: 7.0 M Installed size: 23 M Is this ok [y/d/N]: y Downloading packages: (1/4): gpm-libs-1.20.7-6.el7.x86_64.rpm | 32 kB 00:00:00 (2/4): vim-enhanced-7.4.629-8.el7_9.x86_64.rpm | 1.1 MB 00:00:00 (3/4): vim-filesystem-7.4.629-8.el7_9.x86_64.rpm | 11 kB 00:00:00 (4/4): vim-common-7.4.629-8.el7_9.x86_64.rpm | 5.9 MB 00:00:01 ------------------------------------------------------------------------------------------------------------------------ Total 4.0 MB/s | 7.0 MB 00:00:01 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : 2:vim-filesystem-7.4.629-8.el7_9.x86_64 1/4 Installing : 2:vim-common-7.4.629-8.el7_9.x86_64 2/4 Installing : gpm-libs-1.20.7-6.el7.x86_64 3/4 Installing : 2:vim-enhanced-7.4.629-8.el7_9.x86_64 4/4 Verifying : gpm-libs-1.20.7-6.el7.x86_64 1/4 Verifying : 2:vim-enhanced-7.4.629-8.el7_9.x86_64 2/4 Verifying : 2:vim-common-7.4.629-8.el7_9.x86_64 3/4 Verifying : 2:vim-filesystem-7.4.629-8.el7_9.x86_64 4/4 Installed: vim-enhanced.x86_64 2:7.4.629-8.el7_9 Dependency Installed: gpm-libs.x86_64 0:1.20.7-6.el7 vim-common.x86_64 2:7.4.629-8.el7_9 vim-filesystem.x86_64 2:7.4.629-8.el7_9 Complete! [root@linuxcentos7 ~]# [root@linuxcentos7 ~]# [root@linuxcentos7 ~]# rpm -qa |grep vim vim-minimal-7.4.629-7.el7.x86_64 vim-common-7.4.629-8.el7_9.x86_64 vim-filesystem-7.4.629-8.el7_9.x86_64 vim-enhanced-7.4.629-8.el7_9.x86_64
效果
添加alias,转义:
vim ~/.bashrc alias vi='vim'
[root@linuxcentos7 essential]# vim ~/.bashrc [root@linuxcentos7 essential]# source ~/.bashrc [root@linuxcentos7 essential]# alias alias cp='cp -i' alias egrep='egrep --color=auto' alias fgrep='fgrep --color=auto' alias grep='grep --color=auto' alias l.='ls -d .* --color=auto' alias ll='ls -l --color=auto' alias ls='ls --color=auto' alias mv='mv -i' alias rm='rm -i' alias ss='cd /mnt/hgfs/liugh/studyspace' alias vi='vim' alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
再用vi时,实际用的是vim。
标签:x86,vi,629,vim,64,7.4,linux,文本,el7 From: https://www.cnblogs.com/xinhua219/p/16742379.html