Vi and Emacs


Text Editing: vi

vi filename     If there is no file, vi creates the file.

vi can be in one of the following three modes:

When vi is first loaded, it is in the command mode. This means that all keystrokes entered are interpreted as commands. To return to command mode from input mode, hit <ESCAPE>.

Description Command Code
Move one space to the right Space, l, or right arrow
Move one space to the left h, or left arrow
Move down one line j, or down arrow
Move up one line k , or up arrow
Move one word to the right w, or W
Move one word to the left b, or B
Move to beginning of line 0
Move to end of line $
Move to top of screen H
Move to middle of screen M
Move to bottom of screen L
Save contents to file :w
Quit file :q
Quit vi, saving file only if changes were made :x
Save file and quit vi :wq
Save contents to file and quit vi ZZ
Toggle between uppercase and lowercase ~
Delete back one character X
Delete character under cursor x
Delete line dd
Delete word dw

See the vi notes for more commands and details.

The following commands leave vi in input mode. The table gives the position where the text is inserted.

Description Insert Text
Before cursor i
At beginning of line I
After cursor a
At end of line A
After current line o
Before current line O


Text Editing: emacs