UNIX V: vi
- vi has three modes: a "moving around mode" which is the default,
an "insertion mode" where you can add text to your file just by
typing it, and a "command mode" which is indicated by a colon ":" at the
bottom left corner of the screen with your cursor next to it.
Typing an ESC almost anywhere will get you back into moving around mode.
- Moving around in "moving around mode" is based on the four home keys
of the right hand on the QWERTY keyboard. Typing h moves you
left, j moves you down, k moves you up, and
l moves you right. It is amazing how natural this becomes after
a while.
-------------------------------------------------------------------------------
| Vi Survival Guide |
+------------------------------------------------------------------------------|
|vi filename | How to start up vi. Good luck! |
----------------+--------------------------------------------------------------
|ESC ESC CTRL-L | Panic. Usually fixes things up. |
+------------------------------------------------------------------------------|
|ESC | Gets you out of insert mode. Does nothing in move around |
| | mode. Gets you out of command mode. |
----------------+--------------------------------------------------------------
|CTRL-L | Redisplays the screen |
+------------------------------------------------------------------------------|
|Arrow keys | Move you around if your terminal is set up right. |
----------------+--------------------------------------------------------------
|k | Up one line (Move mode) |
+------------------------------------------------------------------------------|
|CR | Down one line (Move mode) |
----------------+--------------------------------------------------------------
|CTRL-H | Left one space (Move mode) |
+------------------------------------------------------------------------------|
|space | Right one space (Move mode) |
----------------+--------------------------------------------------------------
|$ | Move to the end of the line (Move mode) |
+------------------------------------------------------------------------------|
|0 | Move to the beginning of the line (Move mode) |
----------------+--------------------------------------------------------------
|10G | Go to line 10 (Move mode) |
+------------------------------------------------------------------------------|
|0G | Got to the last line in the file (Move mode) |
----------------+--------------------------------------------------------------
|i | Begin inserting just before the character the cursor is on. |
| Finish with ESCAPE. (Move mode) |
+-----------------------------------------------------------------------------|
|a | Begin inserting just after the character your cursor is on. |
| | Finish with ESCAPE. |
+---------------+--------------------------------------------------------------
|ESCAPE | Terminates insert mode |
+------------------------------------------------------------------------------|
|dd | Deletes the line your cursor is on |
+---------------+--------------------------------------------------------------
|d SPACE | Deletes the character your cursor is on. |
+------------------------------------------------------------------------------|
|dw | Deletes the word your cursor is on. |
----------------+--------------------------------------------------------------
|d10d | Deletes 10 lines starting from the line your cursor is on. |
+------------------------------------------------------------------------------|
|u | Undoes your last edit. |
----------------+--------------------------------------------------------------
|cw | Changes the current word you are on. Terminate with ESCAPE. |
+------------------------------------------------------------------------------|
|r character | Replaces the character directly under the cursor. |
----------------+--------------------------------------------------------------
|R | Goes into replace mode. Allows you to type over characters. |
| | Terminate with ESCAPE. Cursor movements are not allowed. |
+------------------------------------------------------------------------------|
|:wq CR | Command mode. Write the file and quit. |
----------------+--------------------------------------------------------------
|:w CR | Command mode. Write the file and stay. |
+------------------------------------------------------------------------------|
|:q CR | Command mode. Quit the file if no changes. |
----------------+--------------------------------------------------------------
|:quit! CR | Command mode. Quit the file and abandon changes. |
+------------------------------------------------------------------------------|
|ESCAPE | Terminates command mode. Does not execute command. |
-------------------------------------------------------------------------------
Next Slide