This is our VI editor tutorial.

VI stands for visual editor. VI is a text editor used in Unix operating systems. There are many other types of text editors such as EMACS, PICO, and ED; but this tutorial will only focus on VI because it is widely available on Unix and Linux systems.

In VI, there are two modes: insert and command. In the insert mode, you can insert (type) data into a document. In the command mode, you can use the various tools like Microsoft Word's toolbars. VI is a powerful editor because it has a lot of commands. It is also more efficient because the fingers do not need to leave the keyboard. For example, the mouse is useless when using VI. To navigate your way inside a document, you can either use the arrow keys or the h, j, k, l keys. Below is a Java applet that you can use to simulate cursor movements in a vi editor environment. For those that are interested or just nosy :), the java source code can be found here.


Sorry, your web browser does not support java applets.

To start the applet, click on the black screen first and make sure the CAPS LOCK key is off. h is to move left. j is to move down. k is to move up. l is to move right.

When in command mode, you can also move one word forward (w) or one word backward (b). In Microsoft Word, you have to press the CTRL key and the right or left arrow. To move to the end of a document, you press SHIFT + G. In Word, you must press CTRL + END. By always keeping your fingers on the home-key position of the keyboard, precious time is saved.

To start entering data, you must switch to the insert mode. This can be done in various ways:

  • i inserting to the left of the cursor (i for insert)
  • a inserting to the right of the cursor (a for after)
  • I inserting at the beginning of the line
  • A inserting at the end of the line
  • o inserting a line below the cursor
  • O inserting a line above the cursor

To switch to command mode, you hit the ESC key. When in doubt which mode you are in, hit the ESC key. To save a document, you must be in command mode. You save by typing :w and the document will be saved. If you did not initially name your file, you can type :w resume.txt to save your document as resume.txt.

VI is not user friendly because there are no toolbars to use. Hence, it takes a lot of practice to use it efficiently. The more you use it, the more commands you will remember. Below are some more useful commands.

  • x is for deleting a character at the cursor
  • 5x means deleting 5 characters starting from the cursor
  • D is for deleting from the cursor to the end of the line
  • dd is deleting a whole line (and putting it in the buffer [Word's clipboard] aka copying)
  • yy is copying a whole line (y for yanking)
  • 4dd means deleting 4 lines including the line at the cursor
  • P means pasting from the buffer above the cursor's line
  • p means pasting from the buffer below the cursor's line
  • /linux searches for the string linux (press n to go to the next linux, press N to go back)

We hope our little tutorial was helpful to you. Thanks for stopping by.

***Have you ever wondered why VI's cursor is directly on top of a character while Microsoft Word's cursor is between characters? If you know the reason, please email us***.





























Return to Main Index