Insertion commands
- i = insert mode
- a = insert mode (start at end of line)
- I = insert mode (start at beginning of line)
- o = begin insert on new line
- R = overwrite mode
- ESC = Command mode
- : = Last Line Command mode
- u = undo the last action to this file
Deletion commands
- x = Delete char under cursor
- dd = Delete line
- dw = delete to end of word
- d<return> = current line and next
- d0 = delete to beginning of line
- D = delete to end of line
- d)/d( = delete to end/beginning of sentence
- d}/d{ = delete to end/beginning of paragraph
- ndd = delete next n lines
- rc = overwrite current char with c
- ~ = Change case
- . = repeat last command
Navigation
- 0/$$ = beginning and end of line
- 1G/G = beginning and end of file
- nG = nth line in file
- {/} = forward/back one paragraph
- (/) = forward/back one sentence
- H/M = beginning/middle of screen
- CTRL-F/B = Forwards/Backwards one page
- w/W = Next word
- b/B = Previous word
- /<string> = find <string> in file (forwards)
- /?<string> = find <string> in file (backwards)
Reformatting text
- {gq} reformats text of one paragraph.
File I/O commands
- :w = Save
- :wq = Save and quit
- ZZ = Save and quit
- :q! = Quit w/o saving
- :e <file> = Edit another file
- :! <Command> = Shell command
- :r <file> = insert a file into the current one
Buffer commands
- y_ = yank [_ = usual commands. e.g. 0 = beginning of current line, etc]
- Y = yank to end of current line
- p = put buffer contents in after current line
- p = put buffer contents in before current line
- "[a-z]y = yank text into buffer a-z
- "[a-z]p = put text from buffer a-z
- "[a-z]d = delete text and put into buffer a-z
- NB: The last three commands can be qualified as usual. e.g. y) = to end of sentance.
Split screen
- :split splits the screen in two
- CTRL-W [up/down arrow] changes between windows
Misc
- When no text on line, use CTRL-T/D to use auto-indent feature.
- CTRL-Q is the antidote to CTRL-S !!
Automatic line wrapping
- :set wraplength=70 (or :set wl=70)
- :set wraplength=0 (to turn off)
- NB: This doesn't work in vim - use textwidth instead of wraplength
- To get a command that wraps the current paragraph ('q' in command mode):
- map q !}fmt^M
- (use ctrl-V ctrl-M to get ^M)