VI stands for "Visual Interpreter".
It's the only text editor found on every UNIX system.
|
You must be logged onto UNIX , and be in the directory where you want to work.
|
To start, type vi filename (the name of the file you want to edit)--or just vi if you're creating a file but don't want to name it yet.
|
VI has two basic modes--the command mode, and the text-entry mode.
|
When in doubt, hit the escape key which always returns you to the command mode.
|
In comand mode, use your keyboard's arrow keys to navigate. You can also use shift-4 to go to the end of a line, and shift-6 to go to the beginning of a line. Moreover, shift-9 and shift-0, respectively, take you to the beginning and end of a sentence.
|
In command mode, w moves you forward one "word". Furthermore, including a number, such as 8w, will take you forward, in this case, eight words. Similarly, b takes you "back" one word, while 20b, for example, would move you back twenty words.
|
To go into text-entry mode, type i and now you can "insert" new text where the cursor is. In contrast, typing a prepares you to "append" or add new text, AFTER the current cursor position.
|
In command mode, use x to delete characters.
|
In command mode, o will start a new line and put you into text-entry mode.
|
In command mode, use dw to delete a word, dd to delete a line, and d$ to delete to the end of a line.
|
In command mode, you can "undo" your last change with u (but don't follow it with enter). Hitting u again will restore the change, and you can toggle back and forth betwen the two.
|
To save your work, go into command mode and type :w for "write". You'll be asked to name your file if it doesn't already have one.
|
To quit VI, type :q in command mode.
|
The above two commands can be combined as :wq. Furthermore, :q! quits without saving any changes.
|
To learn more VI commands, exit VI and view the online manual by typing man vi
|