Professional Documents
Culture Documents
The Vi Text Editor
The Vi Text Editor
The vi text editor can be used to edit ASCII text files while you are working in a shell
window. It is a standard editor found on most unix systems. To open or create a file in
vi, from your command line type:
vi filename
If you are creating a new file, filename is what you want to call the file. If you are
editing an existing file, type the current filename. The file appears in your shell
window.
Unlike most word processors you may be familiar with, vi has two modes of operation
that you must toggle back and forth between in order to edit your files. One mode is
for inserting text, and the other mode is for moving around or executing commands.
The two modes are called:
When you first enter vi, you are in command mode, and cannot enter text until you
change modes. You can switch to Text input mode by hitting the i key (for insert).
After hitting the i key, any characters you type will be inserted at the current cursor
position. Alternatively you could enter insert mode by pushing the a key (for append),
and characters you type will be appended to the current cursor position. To get back to
escape mode you push the escape key. You need to be in Command mode before you
can quit out of a file.
Short summary of vi Commands.
Use the following commands in Command mode to cut, paste, and move around in the
text. Use them also to switch from Command mode to Text Input mode. Remember to
hit <Esc> or <CTRL 3> whenever you want to switch from Text Input mode to
Command mode.
Adding Text in vi
Use these Command mode keystrokes to switch to Text Input mode (hit <Esc> or
<CTRL 3> to return to Command mode):
Use these Command mode keystrokes to move around within the file: