Understanding VI or VIM


VI OR VIM is the famous and most commonly used text editor for Linux operating systems. In this post, I would like to write shortcuts in VI or VIM which can make text editing easy.

vi” is a text editor from the early days of Unix. It became quite popular and made its way into the Single Unix Specification (SUS) and POSIX, but wasn’t freely available (until 2002).
So several free vi-like editors emerged. Vim (” vi improved”) is one of this editors. As the name suggests it adds a lot of functions to the original vi interface.
In Ubuntu Vim is the only vi-like editor installed by default, and so vi actually starts Vim by default.

vi editor is the most popular text editor in Linux. We can say it has a simple black and white screen i.e. if you type any command there is no code highlighting, whereas vim is improved version of VI it also has features same like vi but it also has code highlighting.

Both have these 4 basic modes:
write mode
command mode
Visual mode
escape mode

Vim has more of everything. In addition to syntax highlighting (when compiled with a support for it) it does automatic conversions of character sets, line-endings and such. It has multiple ways of numbering lines, which is really convenient. Vim certainly has a lot that speaks for it.
Unfortunately, vim breaks the vi philosophy by mixing the editor modes and introducing a vast number of useless and redundant functions. Sure it’s convenient at first that you can for example move with cursor keys in insert mode, but it also has some really weird unwanted side-effects (for example the . gets quirky and unpredictable).
Vim (while certainly being IMproved as it claims) is also a bloated, weird and inconsistent mixture of a broken vi and a modeless editor. 😛

Vim adds onto those features. Here are a some of the extended vim features:

  • Vim has been ported to a much wider range of OS’s than vi.
  • Vim includes support (syntax highlighting, code folding, etc) for several popular programming languages (C/C++, Python, Perl, shell, etc).
  • Vim integrates with cscope.
  • Vim can be used to edit files using network protocols like SSH and HTTP.
  • Vim includes multilevel undo/redo.
  • Vim allows the screen to be split for editing multiple files.
  • Vim can edit files inside a compressed archive (gzip, zip, tar, etc).
  • Vim includes a built in diff for comparing files (vimdiff).
  • Vim includes support for plugins, and finer control over config and startup files.
  • Vim can be scripted with vimscript, or with an external scripting language (e.g. python, perl, shell).

Please refer the below-snippet for shortcuts or tips

vi or vim will open the text editor
vi fileName -- opens/creates vi with the current file
:q - quits vim
i - insert mode
esc - normal mode
:w filename - write to file system with specific file name
:w - write file out if vim already knows the file name
:wq - writes and quits vim
:q! - quits vim when a buffer has edits
shift A - goes into insert mode at end of line (didn't mention on video)

j - down
k - up
h - left
l - right
gg - top of file
G - bottom of tile
number gg - goes to specific line number

/searchTerm - searches for current text
n - goes to the next location of the searched text
?searchTerm - searches backwards for current text
* - searches for the current text the cursor is on

:%s/findText/replaceText - searches all text and replaces text no confirmation.

:%s/findText/repalceText/c - searches text and confirms each replace.

editing mutiple windows:
:split filename - splits the window horizontal
:vsplit filename - splits the window virtual
ctrl-w j - moves to the window down
ctrl-w k - moves to the window up
ctrl-w h - moves to the window to the left
ctrl-w l - moves to the window to the right

v - enter visual mode (select text with hjkl)
y - yanks text
:put - paste text after current line
p - paste at current position

If you need any further assistance contact me @ [email protected] prefer hangout ?

Can also get more details from the below URL:


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.