Although there are many editors and word processors available for Linux, the vi (visual) editor is the standard editor that is available on every Unix and Linux system. You may find vi difficult to learn and use at first, but you will come to appreciate its many powerful features.
The version of vi often found on Linux systems (including ours) is a derivative named vim (vi improved)invoked by typing either vi or vim at the prompt.
The key to using vi is to remember that it was developed before cursor controls like the arrow keys, Page Up/Down keys, and other editing keys were commonly available on keyboards. To work around this, all forms of vi define three different operating modes in addition to any extensions that may have been added:
text insertion (that is. input mode);
cursor movement and simple editing (command mode);
sophisticated editing operations (edit or ed mode).
Therefore each key on the keyboard can have three entirely different meanings, and some have more with various shift combinations. Try both p and P for pasting, for example, in command mode.
When you first start vi, you are in command mode. Press i to enter text input mode and type your material. Return to command mode by using the ESC key to end insert mode. Make changes or corrections from input mode as needed. When you are finished, go to edit mode to save your file and exit. Use :w to write your file to disk, or :w <filename> if it needs a new name, and :q to exit. You may combine :w and :q as :wq.
The diagram below illustrates methods of moving between each mode, and some of the keys available in each mode.
Some basic commands for vi
These basic commands are enough to get you started and to complete most simple editing tasks.
You will often find vi commands in other places as well, either derived from vim itself or often from a common ancestor program. For example, the / and ? search commands work in less and man, and a close relative of :s works in sed.
The use of h, j, k, l is guaranteed to move the cursor on all compatible editors derived from vi, but almost everyone uses the arrow keys.
Try the tutorial (look at :help) in vim for more useful techniques.