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 |
emacs filename If there is no file, emacs creates the file
Note that ``C-x" means ``hold down the Control key, and type the x key". ``M-x" means "type the ESC key, then type the x key". Alternatively, if your terminal has a Meta-key, then ``M-x" means "hold down the Meta key, and type the x key".
| Description | Command Code |
|---|---|
| Exit Emacs | C-x C-c |
| Suspend Emacs | C-z |
| Get help | C-h |
| Save a file | C-x C-s |
| Visit a new file | C-x C-v |
| Visit another buffer | C-x b |
| Abort a command | C-g |
| Down one screen-full | C-v |
| Up one screen-full | M-v |
| Forward one character | C-f |
| Forward one word | M-f |
| Back one character | C-b |
| Back one word | M-b |
| Down to next line | C-n |
| Up to previous line | C-p |
| Go to beginning of line | C-a |
| Go to end of line | C-e |
| Go to begining of file | M-< |
| Go to end of file | M-> |
| Set mark (begin region) | C-@ or C-SPACE |
| Go to mark | C-x C-x |
| Delete previous character (back) | DEL |
| Delete current character (forward) | C-d |
| Delete previous word (back) | M-DEL |
| Delete next work (forward) | M-d |
| Kill rest of line (send to kill buffer) | C-k |
| Delete region (from mark) (send to kill buffer) | C-w |
| Yank back kill buffer | C-y |
| Incremental search forward | C-s |
| Incremental search backward | C-r |
| Exit incremental search | ESC |
| Abort incremental search | C-g |
| Get rid of extra windows | C-x 1 |
| Split window in two | C-x 2 |
| Move cursor to other window | C-x o |
| Start a shell window | M-x shell |
| Run the compiler | M-x compile |
| Move to next compiler error | C-x ` |