Walker News

Why VIM Editor Better Than VI Editor

Vi editor is one of the most common (if not popular) text editor among Linux distributions and UNIX variants. Although, there is an “enhanced” version which is worth to mention.

If you’re running Linux box (in my case, it’s RHEL4) run this command
rpm -qa --last | grep vim
to check if you’ve installed these “enhanced’ vi editor packages:

vim-minimal (e.g. vim-minimal-6.3.046-0.40E.7)
vim-common (e.g. vim-common-6.3.046-0.40E.7)
vim-enhanced (e.g. vim-enhanced-6.3.046-0.40E.7)
In most cases, only the “vim-minimal” is installed. You can locate the other 2 packages from the Linux distribution CD and run these two commands to install (the RPM packages):
rpm -Uvh vim-enhanced-6.3.046-0.40E.7
rpm -Uvh vim-common-6.3.046-0.40E.7

Once the installation completed, logout and login again (or simply run su command to switch user), the new session should has a new command alias that redirect “vi” to “vim” editor (VI-Improved editor), i.e. you should notice this alias in the alias command output:

alias vi=’vim’

The packages installation configure that vi alias command for all login users by creating the these two files:

/etc/profile.d/vim.csh (for those users login with CSH shell)
/etc/profile.d/vim.sh (for those users login with Bash shell)

Some of the good features in vim editor:
Note: vim editor commands are entered inside the editor window, i.e. while in vim editor window, press ESC key follow by entering the editor command, one at a time.
  • :split another_file_name (editor command) to split the editor into a horizontal window so that you could edit / view two files concurrently.
    To split it again for another file named my_file, just enter the :split my_file command. If your LCD monitor is big enough, the split command will be really useful!

    To switch between the horizontal windows, just press CTRL+W hotkey.
  • syntax on or syn on (editor command) is useful to view programming source code. The vim editor will automatically colorized the programming source code according to respective syntax.
  • :color murphy is the best syntax color scheme for my standard (especially when I view the code over ssh session together with brighter LS_COLORS settings and syntax on).
  • Suppose the $HOME/.vimifo file is not tampered and set history=valid_numeric_number is on, vim editor will automatically shift the editing cursor to the last edited line (with reference to the records in $HOME/.viminfo file) upon opening the target file.

In fact, most of vim editor commands can be put into configuration file, either $HOME/.vimrc (applicable to individual user account) or /etc/vimrc that affect all user accounts (the vim editor settings will be superseded by those defined in $HOME/.vimrc).

That’s to say, whenever vim is running to edit / view a file, the editor will read the setting from /etc/vimrc followed by $HOME/.vimrc file.

Custom Search

  1. How To Fix “Server Refused Our Key” Error That Caused By Putty Generated RSA Public Key? 22-03-09@16:17

    […] to the format of OpenSSH-generated public-key: 1) Edit Putty-generated public-key file with Vi editor, Original RSA type of public-key generated by Puttygen program. 2) Delete the first two and the […]

2018  •  Privacy Policy