Basic vi knowledge
vi is included in almost every GNU/Linux or UNIX distribution. "vi" is a truncation of the word "visual". vi is different from most editors in that it has different so-called modes. When you start vi, you are in NORMAL mode. Here every key has some special function. For example, pressing 'x' deletes the character under the cursor. Beginners will start off preferring the INSERT mode; you enter it by pressing 'i' in NORMAL mode. Here letters are letters, backspace is backspace etc – like in any old editor. This is a kind of "safe" mode for beginners, as, unlike in NORMAL mode, keys don't do unexpected things. When you have made the changes you want, switch back to NORMAL mode by pressing . You can always return to insert mode by pressing i. Now you will want to do some special things such as saving.
Here are some command you should know:
|:w <ENTER>||write file|
|:wq <ENTER>||write file and quit|
|:w FILENAME <ENTER>||write file as FILENAME|
|:e FILENAME <ENTER>||edit file FILENAME|
|:q! <ENTER>||quit witdout saving|
Even in NORMAL mode, you can use the arrow keys to navigate, but this always means moving your hand from the letters to the arrow keys and back, resulting in some latency. On laptop keyboards, this is especially inconvieneant. Instead, vi offers the following movement keys:
|h left||l right|
On most keyboards, these keys are under a touch typist's right hand
and thus very accessible. By the way, vi is a perfect editor to learn
typing with ! These keys can be memorized in different ways. h and l are the furthest left and right of the set; the letter j
looks slightly like it's pointing downward and the key usually has a little stud (for finding the key when touch typing) at the bottom.
To learn more about vi editior read the vi survival guide