Ex Quick Reference
Entering/leaving EX
| % ex name | edit name, start at end | 
| %ex +n name | ... starting at line n | 
| % ex -t tag | start at tag | 
| %ex -r | list saved files | 
| %ex -r name | recover file name | 
| %ex name name ... | edit first; rest via :n | 
| %ex -R name | read-onlymode | 
| :x | exit, saving changes | 
| :q! | exit, discaring changes (quit) | 
Ex states
| Command | Normal and inital state. Input prompted for by :. Your kill character cancels partial command. | 
| Insert | Entered by a, i and c. Arbitary text then terminates with line having only . character on it or abnormally with interrupt. | 
| Open/visual | Entered by open or vi, terminates with Q or ^\. | 
Ex cammands
| abbrev | ab | 
| append | a | 
| args | ar | 
| change | c | 
| copy | co | 
| delete | d | 
| edit | e | 
| file | f | 
| global | g | 
| insert | i | 
| join | j | 
| list | l | 
| map | |
| mark | ma | 
| move | m | 
| next | n | 
| number | nu | 
| open | o | 
| preserve | pre | 
| p | |
| put | pu | 
| quit | q | 
| read | re | 
| recover | rec | 
| rewind | rew | 
| set | se | 
| source | so | 
| stop | st | 
| substitute | s | 
| unabbrev | una | 
| undo | u | 
| unmap | unm | 
| version | ve | 
| visual | vi | 
| write | w | 
| xit | x | 
| yank | ya | 
| window | z | 
| escape | ! | 
| lshift | < | 
| print next | <CR> | 
| resubst | & | 
| rshift | > | 
| scroll | ^D | 
Ex Command Addresses
| n | line n | 
| . | current | 
| $ | last | 
| + | next | 
| - | n forward | 
| +n | n forward | 
| /pat | next with pat | 
| ?pat | last with pat | 
| x-n | n before x | 
| x,y | x through y | 
| 'x | marked with x | 
| '' | previous context | 
Specifying Terminal Type
| %setenv TERM type | csh and all version 6 | 
| $ TERM=type;export TERM | version 7 | 
See also rset(1)
Some Terminal Types
- 2621
 - 2645
 - 300s
 - 33
 - 37
 - 4014
 - 43
 - 733
 - 745
 - act4
 - act5
 - adm3
 - adm31
 - adm3a
 - c100
 - dm1520
 - dm2500
 - dm3025
 - dw1
dw2 - gt40
 - gt42
 - h1500
 - h1510
 - h19
 - i100
 - mime
 - owl
 - t1061
 - vt52
  
Initialisation Options
| EXINIT | place set's here in environment var. | 
| set x | enable option | 
| set nox | disable option | 
| set x=val | give value val | 
| set | show changed options | 
| set x? | show value of option x | 
Useful Options
| autoindent | ai | supply indent | 
| autowrite | aw | write before changing files | 
| ignorecase | ic | in scanning | 
| lisp | () {} are s-exp's | |
| list | print ^I for tab, $ at end | |
| magic | .|* special in patterns | |
| number | nu | number lines | 
| paragraphs | para | macro names which start | 
| redraw | simulate smart terminal | |
| scroll | command mode lines | |
| sections | sect | macro names... | 
| shiftwidth | sw | for < >, and input ^D | 
| showmagic | sm | to ) and } as typed | 
| slowopen | slow | choke updates during insert | 
| window | visual mode lines | |
| wrapscan | ws | around end of buffer? | 
| wrapmargin | wm | automatic line splitting | 
Scanning Pattern Formation
| ^ | beginning of line | 
| $ | end of line | 
| . | any character | 
| \< | beginning of word | 
| \> | end of word | 
| [str] | any char in str | 
| [^str] | any char not in str | 
| [x-y] | any char betwene x and y | 
| * | any number of preceding | 
VI Quick Reference
Entering/Leaving VI
| vi name | edit name at top | 
| vi +n name | ... at line n | 
| vi + name | ... at end | 
| vi -r | list saved files | 
| vi -r name | recover name | 
| vi name name ... | edit first; rest via :n | 
| vi -t tag | start at tag | 
| vi +/pat name | search for pat | 
| view name | read-only | 
| ZZ | exit from vi, saving changes | 
| ^Z | stop vi for later resumption (suspend - use fg) | 
The display
| Last line | error messages, echoing input to : / ? | 
| @ lines | On screen only, not in file | 
| ~ lines | lines past end of input | 
| ^x | control characters, ^? Is delete | 
| tabs | expand to spaces, cursor at last | 
VI States
| Command | Normal and initial state. Others return here. ESC (escape) cancels partial command | 
| Insert | Entered by a I A I o O c C s S R. Arbitary text then terminates with interrupt. | 
| Last line | Reading input for : / ? or !; terminate with ESC of CR to execute, interrupt to cancel. | 
Counts Before VI Commands
| line/column number | z G I | |
| scroll amount | ^D ^U | |
| replicate insert | a I A I | |
| repeat effect | most rest | 
Simple Commands
| dw | delete a word | 
| de | ... leaving punctuation | 
| dd | delete a line | 
| 3dd | del 3 lines | 
| itextESC | insert text text | 
| cwnewESC | change word to new | 
| easESC | pluralise word | 
| xp | transpose characters | 
Interrupting/Cancelling
| ESC | end insert or incomplete command | 
| ^? | (delete or rubout) interrupts | 
| ^L | reprint screen if ^? scrambles it | 
File Manipulation
| :w | write back changes | 
| :wq | write and quit | 
| :q | quit | 
| :q! | quit discard changes | 
| :e name | edit file name | 
| :e! | reedit, discard changes | 
| :e + name | edit name from end | 
| :e +n | edit from line n | 
| :e # | edit alternate file | 
| ^[ | synonym for :e # | 
| :w name | write file name | 
| :w! name | overwrite file name | 
| :sh | run shell, then return | 
| :!cmd | run cmd, then return | 
| :n | edit net file in args | 
| :n args | specify new arg list | 
| :f | show current file and line | 
| ^G | synonym for :f | 
| :ta tag | to tag file entry tag | 
| ^] | :ta, following word is tag | 
Positioning within a file
| ^F | forward screenfull | 
| ^B | backward screenfull | 
| ^D | scroll down half screen | 
| ^U | scroll up half screen | 
| G | goto line (end default) | 
| /pat | next line matching pat | 
| ?pat | last line matching pat | 
| n | repeat last / or ? | 
| N | reverse last / or ? | 
| /pat+n | nth line after pat | 
| ?pat?-n | nth line before pat | 
| ]] | next section/function | 
| [[ | previous section/function | 
| % | find matching () { or } | 
Adjusting the Screen
| ^L | clear and redraw | 
| ^R | retype, eliminate @ lines | 
| zCR | redraw, current at top | 
| z- | ... at bottom | 
| z. | at center | 
| /pat/z- | pat line at bottom | 
| zn. | use n line window | 
| ^E | scroll window down one line | 
| ^Y | scroll window up one line | 
Marking and Returning
| `` | previous context | 
| '' | ... at first non-white in line | 
| mx | mark position with letter x | 
| `x | to mark x | 
| 'x | ... at first non-white line | 
Line positioning
| H | home window line | 
| L | last window line | 
| M | middle window line | 
| + | next line, at first non-white | 
| - | previous line, at first non-white | 
| CR | return, same as + | 
| down arrow or j | next line, same column | 
| up arrow or k | previous line, same column | 
Character Positioning
| up arrow | |
| 0 | |
| $ | |
| l or right arrow | forwards | 
| h or left arrow | backwards | 
| ^H | same as back arrow | 
| space | same as right arrow | 
| fx | find x forwards | 
| Fx | ... backwards | 
| tx | upto x forward | 
| Tx | ... backwards | 
| ; | repeat last f F t T | 
| , | inservse of ; | 
| | | to specified column | 
| % | find matching ( { ) or } | 
Words, sentences, paragraphs
| w | word forward | 
| b | ... backweard | 
| e | end of word | 
| ) | next sentence | 
| } | next paragraph | 
| ( | last sentence | 
| { | last paragraph | 
| W | blank delimited word | 
| B | back W | 
| E | end of W | 
Commands for LISP
| ) | Forward s-expression | 
| } | ... but don't stop at atoms | 
| ( | Back s-expression | 
| { | ... but don't stop at atoms | 
Corrections during insert
| ^H | erase last character | 
| ^W | erase last word | 
| erase | same as ^H | 
| kill | erase input this line | 
| \ | escapes ^H, your erase, kill | 
| ESC | ends insertion, back to command | 
| ^? | interrupt, terminate insert | 
| ^D | backtab over autoindent | 
| ^V | quote non-printing character | 
Inser and replace
| a | append after cursor | 
| i | insert before | 
| A | apend at end of line | 
| I | insert before first non-blank | 
| o | open line below | 
| O | open above | 
| rx | replace single char with x | 
| R | replace characters | 
Operators (double to affect lines)
| d | delete | 
| c | change | 
| < | left shift | 
| > | right shift | 
| ! | filter through command | 
| = | indent for LISP | 
| y | yank lines to buffer | 
Miscellaneous Operations
| C | change rest of line | 
| D | delete rest of line | 
| s | substitute chars | 
| S | substitute lines | 
| J | join lines | 
| x | delete chars | 
| X | ... before cursor | 
| Y | yank lines | 
Yank and put
| p | put back lines | 
| P | put before | 
| "xp | put from buffer x | 
| "xy | yank to buffer x | 
| "xd | delete to buffer x | 
Undo, redo, retrieve
| u | undo last change | 
| U | restore current line | 
| . | repeat last change | 
| "dp | retrieve dth last delete |