maart@cs.vu.nl (Maarten Litmaath) (10/05/89)
It'll never end. Many Minor Modifications, some additions. A patch would be twice as big. Still `old' format (what happened to you, Kevin?). Enjoy! : This is a shar archive. Extract with sh, not csh. : This archive ends with exit, so do not worry about trailing junk. : --------------------------- cut here -------------------------- PATH=/bin:/usr/bin:/usr/ucb CTRL_L="`echo L | tr L '\14'`" echo Extracting 'vi.ref.6' sed -e 's/^X//' \ -e "s/^Control-L$/$CTRL_L/" > 'vi.ref.6' << '+ END-OF-FILE ''vi.ref.6' X X X X X X //////////////////////////////////////////////////////////////////////// X / VI REFERENCE (by maart@cs.vu.nl) / X //////////////////////////////////////////////////////////////////////// X X Warning: some vi versions don't support the more esoteric features X described in this document. You can edit/redistribute this document X freely, as long as you don't make false claims on original authorship. X X default values : 1 X ^X : <ctrl>x X [*] : `*' is optional X <*> : `*' must not be taken literally X <sp> : space X <cr> : carriage return X <lf> : linefeed X <ht> : horizontal tab X <esc> : escape X <erase> : your erase character X <kill> : your kill character X <intr> : your interrupt character X <a-z> : an element in the range X N : number (`*' = allowed, `-' = not appropriate) X CHAR : char unequal to <ht>|<sp> X WORD : word followed by <ht>|<sp>|<lf> XControl-L X X X X X X ///////////////// X / move commands / X ///////////////// X X N | Command | Meaning X ---+--------------------+----------------------------------------------- X * | h | ^H | <erase> | <*> chars to the left. X * | j | <lf> | ^N | <*> lines downward. X * | l | <sp> | <*> chars to the right. X * | k | ^P | <*> lines upward. X * | $ | To the end of line <*> from the cursor. X - | ^ | To the first CHAR of the line. X * | _ | To the first CHAR <*> - 1 lines lower. X * | - | To the first CHAR <*> lines higher. X * | + | <cr> | To the first CHAR <*> lines lower. X - | 0 | To the first char of the line. X * | | | To column <*> (<ht>: only to the endpoint). X * | f<char> | <*> <char>s to the right (find). X * | t<char> | Till before <*> <char>s to the right. X * | F<char> | <*> <char>s to the left. X * | T<char> | Till after <*> <char>s to the left. X * | ; | Repeat latest `f'|`t'|`F'|`T' <*> times. X * | , | Idem in opposite direction. X * | w | <*> words forward. X * | W | <*> WORDS forward. X * | b | <*> words backward. X * | B | <*> WORDS backward. X * | e | To the end of word <*> forward. X * | E | To the end of WORD <*> forward. X * | G | Go to line <*> (default EOF). X * | H | To line <*> from top of the screen (home). X * | L | To line <*> from bottom of the screen (last). X - | M | To the middle line of the screen. X * | ) | <*> sentences forward. X * | ( | <*> sentences backward. X * | } | <*> paragraphs forward. X * | { | <*> paragraphs backward. X - | ]] | To the next section (default EOF). X - | [[ | To the previous section (default begin of file). X - | `<a-z> | To the mark. X - | '<a-z> | To the first CHAR of the line with the mark. X - | `` | To the cursor position before the latest absolute X | jump (of which are examples `/' and `G'). X - | '' | To the first CHAR of the line on which the cursor X | was placed before the latest absolute jump. X - | /<string> | To the next occurrence of <string>. X - | ?<string> | To the previous occurrence of <string>. X - | n | Repeat latest `/'|`?' (next). X - | N | Idem in opposite direction. X - | % | Find the next bracket and go to its match X | (also with `{'|`}' and `['|`]'). XControl-L X X X X X X ///////////////////////// X / searching (see above) / X ///////////////////////// X X :ta <name> | Search in the tags file where <name> is X | defined (file, line), and go to it. X ^] | Use the name under the cursor in a `:ta' command. X :[x,y]g/<string>/<cmd> | Search globally [from line x to y] for <string> X | and execute the `ex' <cmd> on each occurrence. X :[x,y]v/<string>/<cmd> | Execute <cmd> on the lines that don't match. X X /////////////////// X / undoing changes / X /////////////////// X X u | Undo the latest change. X U | Undo all changes on a line, while not having X | moved off it (unfortunately). X :q! | Quit vi without writing. X :e! | Re-edit a messed-up file. X X /////////////////////////////////// X / appending text (end with <esc>) / X /////////////////////////////////// X X * | a | <*> times after the cursor. X * | A | <*> times at the end of line. X * | i | <*> times before the cursor (insert). X * | I | <*> times before the first CHAR of the line X * | o | On a new line below the current (open). X | The count is only useful on a slow terminal. X * | O | On a new line above the current. X | The count is only useful on a slow terminal. X * | ><move> | Shift the lines described by <*><move> one X | shiftwidth to the right (layout!). X * | >> | Shift <*> lines one shiftwidth to the right. X * | ["<a-z1-9>]p | Put the contents of the (default undo) buffer X | <*> times after the cursor. X | A buffer containing lines is put only once, X | below the current line. X * | ["<a-z1-9>]P | Put the contents of the (default undo) buffer X | <*> times before the cursor. X | A buffer containing lines is put only once, X | above the current line. X * | . | Repeat previous command <*> times. X | If the last command before a `.' command X | references a numbered buffer, the buffer number X | is incremented first (and the count is ignored): X | X | "1pu.u.u.u.u - `walk through' buffers 1 X | through 5 X | "1P.... - restore them XControl-L X X X X X X ///////////////// X / deleting text / X ///////////////// X X Everything deleted can be stored into a buffer. This is achieved by X putting a `"' and a letter <a-z> before the delete command. The X deleted text will be in the buffer with the used letter. If <A-Z> X is used as buffer name, the adjugate buffer <a-z> will be augmented X instead of overwritten with the text. The undo buffer always X contains the latest change. Buffers <1-9> contain the latest 9 X LINE deletions (`"1' is most recent). X X * | x | Delete <*> chars under and after the cursor. X * | X | <*> chars before the cursor. X * | d<move> | From begin to endpoint of <*><move>. X * | dd | <*> lines. X - | D | The rest of the line. X * | <<move> | Shift the lines described by <*><move> one X | shiftwidth to the left (layout!). X * | << | Shift <*> lines one shiftwidth to the left. X * | . | Repeat latest command <*> times. X X ////////////////////////////////// X / changing text (end with <esc>) / X ////////////////////////////////// X X * | r<char> | Replace <*> chars by <char> - no <esc>. X * | R | Overwrite the rest of the line, X | appending change <*> - 1 times. X * | s | Substitute <*> chars. X * | S | <*> lines. X * | c<move> | Change from begin to endpoint of <*><move>. X * | cc | <*> lines. X * | C | The rest of the line and <*> - 1 next lines. X * | =<move> | If the option `lisp' is set, this command X | will realign the lines described by <*><move> X | as though they had been typed with the option X | `ai' set too. X - | ~ | Switch lower and upper cases. X * | J | Join <*> lines (default 2). X * | . | Repeat latest command <*> times (`J' only once). X - | & | Repeat latest `ex' substitute command, e.g. X | `:s/wrong/good'. X - | :[x,y]s/<p>/<r>/<f>| Substitute (on lines x through y) the pattern X | <p> (default the last pattern) with <r>. Useful X | flags <f> are `g' for `global' (i.e. change every X | non-overlapping occurrence of <p>) and `c' for X | `confirm' (type `y' to confirm a particular X | substitution, else <cr>). Instead of `/' any X | punctuation CHAR unequal to <lf> can be used as X | delimiter. XControl-L X X X X X X /////////////////////////////////// X / substitute replacement patterns / X /////////////////////////////////// X X The basic meta-characters for the replacement pattern are `&' and `~'; X these are given as `\&' and `\~' when nomagic is set. Each instance X of `&' is replaced by the characters which the regular expression X matched. The meta-character `~' stands, in the replacement X pattern, for the defining text of the previous replacement X pattern. Other meta-sequences possible in the replacement pattern X are always introduced by the escaping character `\'. The sequence X `\n' (with `n' in [1-9]) is replaced by the text matched by the X n-th regular subexpression enclosed between `\(' and `\)'. The X sequences `\u' and `\l' cause the immediately following character X in the replacement to be converted to upper- or lower-case X respectively if this character is a letter. The sequences `\U' and X `\L' turn such conversion on, either until `\E' or `\e' is X encountered, or until the end of the replacement pattern. X X ////////////////////////////// X / remembering text (yanking) / X ////////////////////////////// X X With yank commands you can put `"<a-z>' before the command, just as X with delete commands. Otherwise you only copy to the undo buffer. X The use of buffers <a-z> is THE way of copying text to another X file; see the `:e <file>' command. X X * | y<move> | Yank from begin to endpoint of <*><move>. X * | yy | <*> lines. X * | Y | Idem (should be equivalent to `y$' though). X - | m<a-z> | Mark the cursor position with a letter. X X //////////////////////////////////////// X / commands while in append|change mode / X //////////////////////////////////////// X X ^@ | If typed as the first character of the X | insertion, it is replaced with the previous X | text inserted (max. 128 chars), after which X | the insertion is terminated. X ^V | Deprive the next char of its special meaning X | (e.g. <esc>). X ^D | One shiftwidth to the left. X 0^D | Remove all indentation on the current line X | (there must be no other chars on the line). X ^^D | Idem, but it is restored on the next line. X ^T | one shiftwidth to the right X ^H | <erase> | One char back. X ^W | One word back. X <kill> | Back to the begin of the change on the X | current line. X <intr> | like <esc>. XControl-L X X X X X X ///////////////////////////////////////////////// X / writing, editing other files, and quitting vi / X ///////////////////////////////////////////////// X X In `:' `ex' commands `%' denotes the current file, `#' is a synonym for X the alternate file (which normally is the previous file). X Marks can be used for line numbers too: '<a-z>. X In the `:w'|`:f'|`:cd'|`:e'|`:n' commands shell meta-characters can be X used. X X :q | Quit vi, unless the buffer has been changed. X :q! | Quit vi without writing. X ^Z | Suspend vi. X :w | Write the file. X :w <name> | Write to the file <name>. X :w >> <name> | Append the buffer to the file <name>. X :w! <name> | Overwrite the file <name>. X :x,y w <name> | Write lines x through y to the file <name>. X :wq | Write the file and quit vi; some versions quit X | even if the write was unsuccessful! X | Use `ZZ' instead. X ZZ | Write if the buffer has been changed, and X | quit vi. If you have invoked vi with the `-r' X | option, you'd better write the file X | explicitly (`w' or `w!'), or quit the X | editor explicitly (`q!') if you don't want X | to overwrite the file - some versions of vi X | don't handle the `recover' option very well. X :x [<file>] | Idem [but write to <file>]. X :x! [<file>] | `:w![<file>]' and `:q'. X :pre | Preserve the file - the buffer is saved as if X | the system had just crashed; for emergencies, X | when a `:w' command has failed and you don't X | know how to save your work (see `vi -r'). X :f <name> | Set the current filename to <name>. X :cd [<dir>] | Set the working directory to <dir> X | (default home directory). X :cd! [<dir>] | Idem, but don't save changes. X :e [+<cmd>] <file> | Edit another file without quitting vi - the X | buffers are not changed (except the undo X | buffer), so text can be copied from one file to X | another this way. [Execute the `ex' command X | <cmd> (default `$') when the new file has been X | read into the buffer.] <cmd> must contain no X | <sp> or <ht>. See `vi startup'. X :e! [+<cmd>] <file> | Idem, without writing the current buffer. X ^^ | Edit the alternate (normally the previous) file. X :rew | Rewind the argument list, edit the first file. X :rew! | Idem, without writing the current buffer. X :n [+<cmd>] [<files>] | Edit next file or specify a new argument list. X :n! [+<cmd>] [<files>] | Idem, without writing the current buffer. X :args | Give the argument list, with the current file X | between `[' and `]'. XControl-L X X X X X X //////////////////// X / display commands / X //////////////////// X X ^G | Give file name, status, current line number X | and relative position. X ^L | Refresh the screen (sometimes `^P' or `^R'). X ^R | Sometimes vi replaces a deleted line by a `@', X | to be deleted by `^R' (see option `redraw'). X [*]^E | Expose <*> more lines at bottom, cursor X | stays put (if possible). X [*]^Y | Expose <*> more lines at top, cursor X | stays put (if possible). X [*]^D | Scroll <*> lines downward X | (default the number of the previous scroll; X | initialization: half a page). X [*]^U | Scroll <*> lines upward X | (default the number of the previous scroll; X | initialization: half a page). X [*]^F | <*> pages forward. X [*]^B | <*> pages backward (in older versions `^B' only X | works without count). X X If in the next commands the field <wi> is present, the windowsize X will change to <wi>. The window will always be displayed at the X bottom of the screen. X X [*]z[wi]<cr> | Put line <*> at the top of the window X | (default the current line). X [*]z[wi]+ | Put line <*> at the top of the window X | (default the first line of the next page). X [*]z[wi]- | Put line <*> at the bottom of the window X | (default the current line). X [*]z[wi]. | Put line <*> in the centre of the window X | (default the current line). XControl-L X X X X X X //////////////////////////// X / mapping and abbreviation / X //////////////////////////// X X When mapping take a look at the options `to' and `remap' (below). X X :map <string> <seq> | <string> is interpreted as <seq>, e.g. X | `:map ^C :!cc %^V<cr>' to compile from within vi X | (vi replaces `%' with the current file name). X :map | Show all mappings. X :unmap <string> | Deprive <string> of its mapping. When vi X | complains about non-mapped macros (whereas no X | typos have been made), first do something like X | `:map <string> Z', followed by `:unmap <string>' X | (`Z' must not be a macro itself), or switch to X | `ex' mode first with `Q'. X :map! <string> <seq> | Mapping in append mode, e.g. X | `:map! \be begin^V<cr>end;^V<esc>O<ht>'. X | When <string> is preceded by `^V', no X | mapping is done. X :map! | Show all append mode mappings. X :unmap! <string> | Deprive <string> of its mapping (see `:unmap'). X :ab <string> <seq> | Whenever in append mode <string> is preceded and X | followed by a breakpoint (e.g. <sp> or `,'), it X | is interpreted as <seq>, e.g. `:ab p procedure'. X | A `^V' immediately following <string> inhibits X | expansion. X :ab | Show all abbreviations. X :unab <string> | Do not consider <string> an abbreviation X | anymore (see `:unmap'). X @<a-z> | Consider the contents of the named register a X | command, e.g.: X | o0^D:s/wrong/good/<esc>"zdd X | Explanation: X | o - open a new line X | 0^D - remove indentation X | :s/wrong/good/ - this input text is an X | `ex' substitute command X | <esc> - finish the input X | "zdd - delete the line just X | created into register `z' X | Now you can type `@z' to substitute `wrong' X | with `good' on the current line. X @@ | Repeat last register command. XControl-L X X X X X X ///////////////////////////// X / switch and shell commands / X ///////////////////////////// X X Q | ^\ | <intr><intr> | Switch from vi to `ex'. X : | An `ex' command can be given. X :vi | Switch from `ex' to vi. X :sh | Execute a subshell, back to vi by `^D'. X :[x,y]!<cmd> | Execute a shell <cmd> [on lines x through y; X | these lines will serve as input for <cmd> and X | will be replaced by its standard output]. X :[x,y]!! [<args>] | Repeat last shell command [and append <args>]. X :[x,y]!<cmd> ! [<args>] | Use the previous command (the second `!') in a X | new command. X [*]!<move><cmd> | The shell executes <cmd>, with as standard X | input the lines described by <*><move>, X | next the standard output replaces those lines X | (think of `cb', `sort', `nroff', etc.). X [*]!<move>!<args> | Append <args> to the last <cmd> and execute it, X | using the lines described by the current X | <*><move>. X [*]!!<cmd> | Give <*> lines as standard input to the X | shell <cmd>, next let the standard output X | replace those lines. X [*]!!! [<args>] | Use the previous <cmd> [and append <args> to it]. X :x,y w !<cmd> | Let lines x to y be standard input for <cmd> X | (notice the <sp> between `w' and `!'). X :r!<cmd> | Put the output of <cmd> onto a new line. X :r <name> | Read the file <name> into the buffer. XControl-L X X X X X X ////////////// X / vi startup / X ////////////// X X vi [<files>] | Edit the files, start with the first page of X | the first file. X X The editor can be initialized by the shell variable `EXINIT', which X looks like: X X EXINIT='<cmd>|<cmd>|...' X <cmd>: set options X map ... X ab ... X export EXINIT (in the Bourne shell) X X However, the list of initializations can also be put into a file. X If this file is located in your home directory, and is named `.exrc' X AND the variable `EXINIT' is NOT set, the list will be executed X automatically at startup time. However, vi will always execute the X contents of a `.exrc' in the current directory, if you own the file. X Else you have to give the execute command yourself: X X :source file X or X :so file X X On-line initializations can be given with `vi +<cmd> file', e.g.: X X vi +x file | The cursor will immediately jump to line x X | (default last line). X vi +/<string> file | ~ to the first occurrence of <string>. X X You can start at a particular tag with: X X vi -t <tag> | Start in the right file in the right place. X X Sometimes (e.g. if the system crashed while you were editing) it is X possible to recover files lost in the editor by `vi -r file'. If X you just want to view a file by using vi, and you want to avoid any X change, instead of vi you can use the `view' or `vi -R' command: X the option `readonly' will be set automatically (with `:w!' you can X override this option). XControl-L X X X X X X ////////////////////////////// X / the most important options / X ////////////////////////////// X X ai | autoindent - In append mode after a <cr> the X | cursor will move directly below the first X | CHAR on the previous line. However, if the X | option `lisp' is set, the cursor will align X | at the first argument to the last open list. X aw | autowrite - Write at every shell escape. X | (useful when compiling from within vi) X dir=<string> | directory - The directory for vi to make X | temporary files (default `/tmp'). X eb | errorbells - Beeps when you goof X | (not on every terminal). X ic | ignorecase - No distinction between upper and X | lower cases when searching. X lisp | Redefine the following commands: X | `(', `)' - move backward (forward) over X | S-expressions X | `{', `}' - idem, but don't stop at atoms X | `[[', `]]' - go to previous (next) line X | beginning with a `(' X | See option `ai'. X list | <lf> is shown as `$', <ht> as `^I'. X magic | If this option is set (default), the chars `.', X | `[' and `*' have special meanings within search X | and `ex' substitute commands. To deprive such a X | char of its special function it must be preceded X | by a `\'. If the option is turned off it's just X | the other way around. Meta-chars: X | ^<string> - <string> must begin the line X | <string>$ - <string> must end the line X | . - matches any char X | [a-z] - matches any char in the range X | [<string>] - matches any char in <string> X | [^<string>] - matches any char not in <string> X | <char>* - 0 or more <char>s X | \<<string>\> - <string> must be a word X nu | number - Numbers before the lines. X para=<string> | paragraphs - Every pair of chars in <string> is X | considered a paragraph delimiter nroff macro X | (for `{' and `}'). A <sp> preceded by a `\' X | indicates the previous char is a single letter X | macro. `:set para=P\ bp' introduces `.P' and X | `.bp' as paragraph delimiters. Empty lines and X | section boundaries are paragraph boundaries too. X redraw | The screen remains up to date. X remap | If on (default), macros are repeatedly X | expanded until they are unchanged. X | Example: if `o' is mapped to `A', and `A' X | is mapped to `I', then `o' will map to `I' X | if `remap' is set, else it will map to `A'. X report=<*> | Vi reports whenever e.g. a delete X | or yank command affects <*> or more lines. X ro | readonly - The file is not to be changed. X | However, `:w!' will override this option. XControl-L X X X X X X sect=<string> | sections - Gives the section delimiters (for `[[' X | and `]]'); see option `para'. A `{' beginning a X | line also starts a section (as in C functions). X sh=<string> | shell - The program to be used for shell escapes X | (default `$SHELL' (default `/bin/sh')). X sw=<*> | shiftwidth - Gives the shiftwidth (default 8 X | positions). X sm | showmatch - Whenever you append a `)', vi shows X | its match if it's on the same page; also with X | `{' and `}'. If there's no match, vi will beep. X terse | Short error messages. X to | timeout - If this option is set, append mode X | mappings will be interpreted only if they're X | typed fast enough. X ts=<*> | tabstop - The length of a <ht>; warning: this is X | only IN the editor, outside of it <ht>s have X | their normal length (default 8 positions). X wa | writeany - No checks when writing (dangerous). X warn | Warn you when you try to quit without writing. X wi=<*> | window - The default number of lines vi shows. X wm=<*> | wrapmargin - In append mode vi automatically X | puts a <lf> whenever there is a <sp> or <ht> X | within <wm> columns from the right margin. X ws | wrapscan - When searching, the end is X | considered `stuck' to the begin of the file. X X :set <option> | Turn <option> on. X :set no<option> | Turn <option> off. X :set <option>=<value> | Set <option> to <value>. X :set | Show all non-default options and their values. X :set <option>? | Show <option>'s value. X :set all | Show all options and their values. X X X ///////////////// X / contributions / X ///////////////// X X Maarten Litmaath <maart@cs.vu.nl> X Rich Salz <rsalz@bbn.com> X Eamonn McManus <emcmanus@cs.tcd.ie> X Diomidis Spinellis <diomidis%ecrcvax.uucp@pyramid.pyramid.com> X Blair P. Houghton <bph@buengc.bu.edu> X Rusty Haddock <{uunet,att,rutgers}!mimsy.umd.edu!fe2o3!rusty> X Panos Tsirigotis <panos@boulder.colorado.edu> X David J. MacKenzie <djm@wam.umd.edu> X Kevin Carothers <kevin@ttidca.tti.com> X Dan Mercer <mercer@ncrcce.StPaul.NCR.COM> X X Patchlevel: 6 + END-OF-FILE vi.ref.6 chmod 'u=rw,g=r,o=r' 'vi.ref.6' set `wc -c 'vi.ref.6'` count=$1 case $count in 30846) :;; *) echo 'Bad character count in ''vi.ref.6' >&2 echo 'Count should be 30846' >&2 esac exit 0 -- Did Andy Tanenbaum get his programming |Maarten Litmaath @ VU Amsterdam: instruction from a Cereal box? (Sam McCrea)|maart@cs.vu.nl, mcvax!botter!maart