How to install and highlight VI editor syntax with VIM
To install and highlight VI editor syntax with VIM
This article explains how to install and enable Syntax Highlighting in VI editor or Vim ( Vi IMproved )on RHEL / CentOS / Fedora.
To Install VIM
Syntax
yum -y install vim-enhanced
Output
[root@linuxhelp Desktop]# yum -y install vim-enhanced
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
* base: ftp.iitm.ac.in
* extras: ftp.iitm.ac.in
* updates: ftp.iitm.ac.in
Setting up Install Process
..
..
..
Dependency Installed:
vim-filesystem.x86_64 2:7.4.629-5.el6
Updated:
vim-enhanced.x86_64 2:7.4.629-5.el6
Dependency Updated:
vim-common.x86_64 2:7.4.629-5.el6
Complete!
To Enable Syntax Highlighting in VI
To Enable Syntax Highlighting in VI and VIM and to add alias function to VI by pointing to VIM, just mention as follows
alias vi=vim
Example
[root@linuxhelp Desktop]# vi /etc/profile
# /etc/profile
# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc
# It' s NOT a good idea to change this file unless you know what you
# are doing. It' s much better to create a custom.sh shell script in
# /etc/profile.d/ to make custom changes to your environment, as this
# will prevent the need for merging in future updates.
alias vi=vim
pathmunge () {
This given function will set the alias globally.
To set user specific aliases and functions
Example
[root@linuxhelp Desktop]# vi /home/user1/.bashrc
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ] then
. /etc/bashrc
fi
# User specific aliases and functions
alias vi=vim
To reset the changes
Execute the following command to reset the changes
[root@linuxhelp Desktop]# source /etc/profile
OR
[root@linuxhelp Desktop]# source /home/user1/.bashrc
To Test Syntax Highlighting in VI
To turn On or turn Off syntax highlighting
[root@linuxhelp Desktop]# vim /etc/vimrc
To turn on
To turn off
Tag :
Text Editor
Q
Where and how to create the alias for vi to vim?
A
The following step is used to set alias name for vim editor
# vi /etc/profile
alias vi=vim // add this line at the end of the file
# source /etc/profile
# vi /etc/profile
alias vi=vim // add this line at the end of the file
# source /etc/profile
Q
Where to set a user-specific alias for vim?
A
For setting user-specific alias, Go to user home path and add the following line in “.bashrc” file
alias vi=vim
alias vi=vim
Q
Where to disable this highlighting in vim editor?
A
You can Disable the highlighting in "/etc/vimrc" file. Open the file and search for a line "syntax on". In that line change "on" into "off". And then save the file and exit from the file.
Q
How to install vim-enhanced on centos?
A
For install in Red Hat based distro’s:
# yum install vim-enhanced
# yum install vim-enhanced
# apt-get install vim-enhanced