Next / Previous / Contents / TCC Help System / NM Tech homepage


Describes common operations in the vi text editor.

This publication is available in Web form and also as a PDF document. Please forward any comments to

Table of Contents

1. What is vi?
2. Starting vi
3. Moving around
4. Searching
5. Editing files
6. Colon (“:”) commands

1. What is vi?

vi's power is in the fact that it was designed for powerful text manipulation and quick movement using only a keyboard. It is also pretty standard (although I won't guarantee that all commands listed here will work on all variants) and very small.

These may not be all the commands or combinations of commands for vi. I tried to include here only what I consider the most standard and most useful vi commands. I can't guarantee that all these commands will work in all vi versions.

Most of these commands are for command mode (also known as escape mode; just hit the esc key a couple of times and you'll be in command mode; usually once will do it, unless you have given it certain commands).

The carat (^) symbol indicates a control character. For example, to get ^F (“control-F”), hold down the control key and then press F.

When a command says can be enumerated, that means that you can repeat that command a certain number of times if you precede it by the number of times you want it to be repeated. This has different effects with different commands: “3dd” will delete three lines and put them all into the buffer (clipboard, to you Windows people). “3p” will put three instances of whatever's in the buffer after the cursor. So if you use “3dd” followed by “3p”, you will end up with nine lines of text where there were three.

Almost all commands can be enumerated. Unless otherwise stated, “current word” or “current character” usually refers to the word under the cursor (the word that contains the letter under the cursor) and the character under the cursor.

A lot of special characters are used for commands in vi, but there is one that will get mentioned only here: the colon (“:”). Use it to go to the special or file command mode where you can do things like saving files. All commands that are used in this mode are preceded by a colon.