Vi Cheat Sheet
There are two modes in which you use vi.
Command mode
This is the mode you are in whenever you begin to use vi. In this mode commands are used to move around and edit text objects such as wordt, sentences and paragraphs.
Pressing the ESC key returns you to command mode.
Insert mode
This is the mode you use to type (insert) text . Tou can enter this mode by hitting the "i" letter while in the command mode. In this mode you can type whatever you want and then later save it or delete it.
Exitting the Insert mode :
after you finish editing you can leave the insert mode by hitting the Esc buttom, this will put you in the command mode.
To open a file using the Vi text editor just type
vi [file name]
For example
vi test.txt
creats the file test.txt which is a text file. This will put you in the command mode in the Vi text editor to switch to the Insert mode press "i", now you can write whatever you like, then when you finish press Esc this will take to the command mode again to write the file and quit you should type wq
Saving and exiting :
To save what you editted you simply switch to the command mode and type
:w
this will save your work. to exit type
:q
you can combine the two commands by typing
:wq
to leave without saving
:q!
to save to another file
:w [filename]
Viewing files.
you can view a file without the risk of altering the file by typing
view [file name]
Deleting text.
In the command mode you can erase the character under the blinking curser by hitting the "x" button, to delete a whole line hit"dd"
Search for text.
to searc for test type, in the command mode,
/stringname