Vim vs Vi – Similarities and Differences Between VIM and VI?

Filed Under: UNIX/Linux
Vi Vs Vim

Vim and Vi are both text editors available in Linux. Vi stands for Visual since it is a visual editor. Vim is short for Vi Improved. The two editors are very similar to each other. However, Vim offers some additional functionalities over the Vi editor.

In this tutorial we will look at the differences and similarities between the two.

What’s similar in VIM and the VI editor

Let’s look at the points of similarities between the two editors.

Opening a file VIM vs VI

The way to open a new or an existing file is the same for the two. The syntax is as follows.

Vi Editor

To open a new file in Vi editor use:

Vi [filename] 

Vim Editor

To open a new file in Vim editor use:

Vim [filename]

Editor Interface VIM vs VI

Both the editors are similar in their appearance.

Vi Editor

Vi editor screen looks like as shown.

Vi Screen
Vi Screen

Vim Editor

The screen in Vim editor looks like as shown.

Vim Screen
Vim Screen

You can see that there is no difference in the appearance of the two.

Modes in VIM vs VI

Both the editors are mode based, that is you need to enter INSERT mode to edit and COMMAND mode to perform actions like saving and undo.

The three modes are as follows:

  • Normal (Default): For navigation
  • Insert: For inserting and modifying text
  • Command: For Operations like saving, exiting, etc.

By default, you are in Normal mode. In normal mode, you can just view your text and navigate through it (more on that later).

Insert mode allows you to make changes to your content.

The command mode is for specifying commands to exit, save your work, and perform other operations. 

To enter command-line mode hit the “Escape” key and then type in the colon ‘:’. To enter insert mode, hit the “Escape” key and type in ‘i’. To enter Normal mode press Escape.

Navigating within the editor interfaces

Shortcuts for navigating within VIM vs VI are the same.

hMove the cursor to left by one position
iMove the cursor to right by one position
jMove the cursor to downward direction by one line
kMove the cursor to upward direction by one line

Searching for text

Both the editors provide the option to search for text in the file.

To search in the file you must be in command line mode. So start by pressing colon (:).

To search for a word use forward slash followed by the word to search followed by enter.

/{word-to-be-searched} [enter]

Improvements in Vim – The differences between VIM vs VI

Vim editor differs from Vi editor since it provides a lot of improvements over the latter. The command to display the points of difference within the Vim editor is:

:help vi_diff
Difference

You can scroll through the list to go over the differences.

In this tutorial, we are going to look at some of the major improvements offered by Vim.

Multiple Undo in VIm

Vi editor only offers the option to perform one undo. This can be very limiting in the case of a large text file.

Vim editor on the other hand offers the ability to perform multiple undo.

Vim provides a multi-level undo which by default goes up to 1,000 changes.

The command to perform undo is :

:u

Portability and Cross-Platform Availability

Vi is only available on Unix. Whereas, Vim works on MS-Windows, Macintosh, Amiga, OS/2, VMS, QNX, and other systems. Vim also works on every Unix system.

This portability of Vim makes it much more popular as compared to the Vi editor.

Syntax Highlighting

Vim offers the ability to highlight syntax in the buffer. This improvement over Vi comes in handy for programmers using Vim to write/edit code.

To enter syntax highlighting mode in Vim first enable command mode using colon (:).

Then type the following:

syntax on

Press Enter.

To disable syntax highlighting type :

syntax off

Press Enter.

Flexible insert mode

Vi editor does not allow navigation using arrow keys while in insert mode. That makes Vi editor inconvenient to navigate around in insert mode.

Vim editor on the other hand allows navigation using arrow keys in inset mode.

Command History

Vi editor does not give you the option to go through commands you have executed.

Whereas Vim editor lets you go through command history, redo the commands or edit then redo the command.

Visual mode

Visual mode lets you highlight a piece of text and then perform operations on it.

To start Visual mode in Vim editor use v or V.

Vi editor does not have a visual mode.

Conclusion

This tutorial was about the differences and similarities between Vim and Vi editor. To learn more about the differences read this official document. Check this writeup to learn some of the interesting VIM commands.

Comments

  1. Dave says:

    This is quite wrong in places. Your article here is misleading.

    It looks like the “vi” you are showing may just be a symlink to “vim”.
    Maybe it is vim-tiny or vim-minimal, bit still some form of “vim”.
    Your first supposed screenshot of “vi” shows that.
    Next time try “:ver” to check what you are actually using.

    Original vi does not have that sort of “ruler” with the row and column at the bottom.
    In fact while nvi (New vi) DOES have a ruler, it is formatted differently.

    There are many assertions and assumptions in the article that seem to ignore the ACTUAL similarities and differences.
    For one, while “vi” does not have a “Visual mode”, it arguably does not NEED one since “Marks” have been a part of “vi” since the late 1970’s.
    Second, “vi” is not ONLY available on Unix. The source code can be compiled on almost any system.
    In fact, it is the DEFAULT vi implementation on Arch Linux as opposed to many systems that symlink “vi” to vim and ignore all the ways that vi and vim are different.
    You don’t even touch on the biggest complaint (aside from compatibility) that vi users have: how slow and bloated “vim” has become. 30MB+ for vim and it’s dependencies vs. ~ 250K for vi and ~ 470k for nvi!

    By the way, vi itself only has _2_ modes: Command mode & Insert mode
    There is no such thing as “Normal” mode; you “navigate” in Command mode.

    I recommend people who are curious about the true “differences” start with something like “Your problem with Vim is that you don’t grok vi.” by Jim Dennis on StackOverflow and go from there.
    But the reality is that only serious Unix / Linux sysadmins will even care about the differences.
    Many people are just worried if their arrow keys work in Insert mode.
    See above about how you are supposed to Navigate in Command mode.

    Sorry. I don’t mean to trash your article. Just some things to consider.

Leave a Reply

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

close
Generic selectors
Exact matches only
Search in title
Search in content