| <ESC> | key (to make sure you are in Normal mode). |
| The cursor is moved using either the arrow keys or the hjkl keys. | |
| h (left) j (down) k (up) l (right) | |
| e | Move cursor to end of word |
| :q! | <ENTER>. This exits the editor DISCARDING any changes you have made. |
| :wq | To save a file and exit. ** |
| :w | <filename> write file to new file name |
| x | To delete the character under the cursor. ** |
| i | To insert text |
| a | To append text after cursor |
| A | Insert text at end of line |
| d | Is the delete operator. |
| dw | To delete a word. ** |
| d$ | To delete to the end of the line. ** |
| de | To the end of the deletion current word INCLUDING the last character. |
| d2w | To delete the two words [d - delete] [times - #] [w - word] |
| 0 | (zero) to move to the start of the line. |
| 2w | To move the cursor two words forward. |
| 3e | To move the cursor to the end of the third word forward. |
| dd | To delete the line. |
| 2dd | To delete two lines. |
| u | To undo the last commands |
| U | To fix a whole line. ** |
| CTRL-R | To redo commands (undo the undo's). |
| p | Put the line below the cursor. |
| rx | To replace the character at the cursor with x . ** |
| c | [number] motion |
| ce | To change until the end of a word |
| c$ | The rest of the line like the second and press <ESC>. |
| CTRL-G | To show your location in the file and the file status. |
| G | To move you to the bottom of the file. |
| gg | To move you to the start of the file. |
| [#]G | To move to a line in the file. Type the number of the line then G |
| / | In Normal mode type the / character. Enter command mode |
| 'errroor' | <ENTER>. This is the word you want to search for |
| n | To search for the same phrase again. |
| N | To search for the same phrase in the opposite direction |
| ? | To search for a phrase in the backward direction instead of / |
| CTRL-O | To go back to where you came from press Repeat to go back further. |
| CTRL-I | Goes forward. |
| % | To find a matching ), ], } |
THE SUBSTITUTE COMMAND | |
| :s/old/new To substitute new for the first old in a line type | |
| :s/old/new/g To substitute new for all 'old's on a line type | |
| :#,#s/old/new/g To substitute phrases between two line #'s type | |
| :%s/old/new/g To substitute all occurrences in the file type | |
| :%s/old/new/gc To ask for confirmation each time add 'c' | |
| EXECUTE AN EXTERNAL COMMAND | |
| :!<command> | followed by an external command to execute that command. ** ie - :!ls -asl |
| :w FILENAME | ** save file name |
| v | Visual Selection To select "highlight" section of file to write to another file :'<,'> will appear on command line. TYPE w <FILENAME TO WRITE> enter
|
| v | is a motion of selection and you can write the selection to disk. Or hitting 'd' delete the selection |
| r | To insert the contents of a file type :r FILENAME ** |
| o | To open a line below the cursor and place you in Insert mode. ** |
| O | To open a line above the cursor and place you in Insert mode. ** |
| R | To replace more than one character. ** |
| y | To yank (copy) the highlighted text. |
| P | To put (paste) the text. Then type: a second <ESC> . |
| j$ | Move Cusor To End J right $ End |
| :set ic | (Ignore case) option |
| :set hlsearch | Highlight Search |
| :set incsearch | ingore case |
| :set noic | ignore case off |
If you're new to VIM/VI at any UNIX prompt type in vmtutor and READ and DO!