EDIT TEXT WITH THE VI EDITOR

There are two basic editors on virtually every UNIX system: Emacs and vi. Of the two, vi is typically the one you'll find on most systems, because Emacs is much larger in size.

Everyone who uses Linux should know some basics about editing text with vi, in case you can't get into X to edit text with your favorite text editor. For example, what happens when you need to modify your X configuration files because X won't start? Obviously, using a KDE text editor is out of the question.

Use this command to open a text file in vi:

vi filename

This opens the file in command mode. However, to edit the text, you must push "i" for insert mode. Navigate around the document by using the arrow keys, plus the [Home] and [End] keys.

To return to command mode, press [Esc]. Now you can use additional keys to move around the document. For example, to go to the first line in a document, press "H" (home), to go to the middle of the document, press "M", and to go to the last line in the document, press "L".

In command mode, you can also save the file by typing :w, which tells vi to write the file to disk. If you want to quit without saving changes, type :q. If you want to quit and write your changes to disk, type :wq or :x.

There are many more commands in vi, but these are the basics that will allow you to edit text in a crunch.