CMP051 - Mini vi manual

Many students have enquired about using the vi editor.
Here is my mini-manual.

Starting vi

To start vi, type vi and the name of the file you wish to edit. This can be a new file e.g.
vi print

Commands

Start editing Esc i


Insert a line (after this line) Esc o
Insert a line (before this line) Esc O (capital O not number 0)


Delete character to the right Esc x
Delete a character to the left Esc X
Delete this line Esc d d


Go to the start of the line Esc 0 (number 0 not capital O)
Go to the end of the line Esc $


Save the file and exit Esc :wq
Exit WITHOUT SAVING Esc :q!