maart@cs.vu.nl (Maarten Litmaath) (08/02/89)
: 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
echo Extracting 'vi.ref'
sed 's/^X//' > 'vi.ref' << '+ END-OF-FILE ''vi.ref'
X////////////////////////////////////////////////////////////////////////
X/ VI REFERENCE (by maart@cs.vu.nl) /
X////////////////////////////////////////////////////////////////////////
X
Xdefault 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<del> : delete
X<a-z> : an element in the range
XN : number (* = allowed, - = not used)
XCHAR : char unequal to <ht>|<sp>
XWORD : word followed by <ht>|<sp>|<lf>
X
X/////////////////
X/ move commands /
X/////////////////
X
X N | Command | Meaning
X---+--------------------+------------------------------------------------------
X * | h | ^H | <*> 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 { } and [ ])
X
X/////////////////////////
X/ searching (see above) /
X/////////////////////////
X
X^] | search in the tags file where the function under the
X | cursor is defined (file, line) and go to it
X:[x,y]g/<string>/<cmd> | search globally [from line x to y] after <string>
X | and execute the "ex" <cmd> on each occurrence
X
X///////////////////
X/ undoing changes /
X///////////////////
X
Xu | undo the latest change
XU | undo all changes on a line, while not having moved
X | 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 * | . | repeat latest command <*> times
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, below
X | 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, above
X | the current line
X
X/////////////////
X/ deleting text /
X/////////////////
X
XEverything deleted can be stored into a buffer. This is achieved by putting a
X" and a letter <a-z> before the delete command. The deleted text will be in
Xthe buffer with the used letter. If <A-Z> is used as buffer name, the adjugate
Xbuffer <a-z> will be augmented instead of overwritten with the text. The undo
Xbuffer always contains the latest change. Buffers "<1-9> contain the latest 9
XLINE 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, append <*> - 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 will
X | realign the lines described by <*><move> as though
X | they had been typed with the option '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//////////////////////////////
X/ remembering text (yanking) /
X//////////////////////////////
X
XWith yank commands you can put "<a-z> before the command, just as with
Xdelete commands. Otherwise you only copy to the undo buffer. The use of buffers
X<a-z> is THE way of copying text to another 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 insertion, it
X | is replaced with the previous text inserted (max. 128
X | chars), after which 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
X0^D | remove all indentation on the current line
X | (there must be no other chars on the line)
X^^D | idem, except that it is restored on the next line
X^T | one shiftwidth to the right
X^H | one char back
X^W | one word back
X^U | back to the begin of the change on the current line
X | (generally your kill char)
X<del> | like <esc>
X
X/////////////////////////////////////////////////
X/ writing, editing other files, and quitting vi /
X/////////////////////////////////////////////////
X
X:q | quit vi after writing
X:q! | quit vi without writing
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, WITHOUT checking if the
X | write has been successful (use "ZZ" instead)
XZZ | write if the buffer has been changed, and quit vi.
X | if you have invoked vi with the "-r" option, you'd
X | better write the file explicitly ("w" or "w!"), or
X | quit the editor explicitly ("q!") if you don't want
X | to overwrite the file - some versions of vi don't
X | handle the "recover" option very well
X:x | idem
X:x! | ":w!" and ":q"
X:e <file> | edit another file without quitting vi - the buffers
X | are not changed (except the undo buffer), so text can
X | be copied from one file to another this way
X:e! <file> | idem, without writing the current buffer
X:e# | edit the previous file
X^^ | idem
X:rew | edit the first file (when "vi file1 file2 ...")
X:rew! | idem, without writing the current buffer
X:n [<file>] | edit the next file
X:n! [<file>] | idem, without writing the current buffer
X
X////////////////////
X/ display commands /
X////////////////////
X
X^G | give current line number and relative position
X^L | refresh the screen (sometimes "^P" or "^R")
X^R | sometimes vi replaces a deleted line by a '@', to be
X | deleted by "^R" (also with option 'noredraw')
X[*]^E | scroll <*> lines downward
X[*]^Y | scroll <*> lines upward
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 only ^B works)
X
XIf in the next commands the field <wi> is present, the windowsize will change
Xto <wi>. The window will always be displayed at the 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)
X
X////////////////////////////
X/ mapping and abbreviation /
X////////////////////////////
X
XWhen mapping turn off the option 'timeout' by ":set noto", and with 'map!'
Xturn on 'remap' by ":set remap".
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 % by the current file name)
X:map | show all mappings
X:unmap <string> | deprive <string> of its mapping
X | when vi complains about non-mapped macros (whereas
X | no typos are made), first do something like
X | ":map <string> Z", followed by ":unmap <string>"
X | ('Z' must not be a macro itself)
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 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 followed by a
X | breakpoint (e.g. <sp> or ','), it is interpreted as
X | <seq>, e.g. ":ab p procedure"
X | a char preceded by ^V is not considered a breakpoint
X:ab | show all abbreviations
X:unab <string> | do not consider <string> an abbreviation anymore
X | (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 "ex"
X | substitute command
X | <esc> - finish the input
X | "zdd - delete the line just created,
X | into register 'z'
X | now you can type @z to substitute 'wrong' by 'good'
X | on the current line
X@@ | repeat last register command
X
X/////////////////////////////
X/ switch and shell commands /
X/////////////////////////////
X
XQ | <del><del> | 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:!<cmd> | execute a shell <cmd>
X:!! | repeat the last shell command
X[*]!<move><cmd> | the shell executes <cmd>, with as standard input the
X | lines described by <*><move>, next the standard
X | output replaces those lines
X | (think of cb, sort, nroff, etc.)
X[*]!!<cmd> | give <*> lines as standard input to the shell <cmd>,
X | next let the standard output replace those lines
X:x,y w !<cmd> | let lines x to y be standard input for <cmd>
X | (notice the space 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
X
X//////////////
X/ vi startup /
X//////////////
X
Xvi [file] : edit the file and display the first page
X
XThe editor can be initialized by the shell variable EXINIT, which looks like:
X
X EXINIT='<cmd>|<cmd>|...'
X <cmd>: set options
X map ...
X ab ...
X export EXINIT (in the Bourne shell)
X
XHowever, the list of initializations can also be put into a file. If this
Xfile is located in your home directory, and is named ".exrc" AND the
Xvariable EXINIT is NOT set, the list will be automatically excuted at
Xstartup time. If the 3 conditions are not met, you have to give the execute
Xcommand yourself:
X
X :source file
Xor
X :so file
X
XOn-line initializations can be given with "vi +<cmd> file", e.g.:
X
Xvi +x file : the cursor will immediately jump to line x
Xvi +/<string> file : ~ to the first occurrence of <string>
X
XSometimes (e.g. if the system crashed while you were editing) it is possible
Xto recover files lost in the editor by "vi -r file".
XIf you just want to view a file by using vi, and you want to avoid any change,
Xinstead of vi you can use the "view" command: the option 'readonly' will be set
Xautomatically (with ":w!" you can override this option).
XThe most important options are:
X
Xai | autoindent - in append mode after a <cr> the cursor
X | will move directly below the first CHAR on the
X | previous line.
X | however, if the option 'lisp' is set, the cursor
X | will align at the first argument to the last open
X | list.
Xaw | autowrite - write at every shell escape
X | (useful when compiling from within vi)
Xdir=<string> | directory - the directory for vi to make temporary
X | files (default /tmp)
Xeb | errorbells - beeps when you goof
X | (not on every terminal)
Xic | ignorecase - no distinction between upper and lower
X | cases when searching
Xlisp | 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 beginning
X | with a '('
X | see option 'ai'
Xlist | <lf> is shown as '$', <ht> as '^I'
Xmagic | some metachars can be used when searching:
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
Xnu | number - numbers before the lines
Xpara=<string> | paragraphs - every pair of chars in <string> is
X | considered a paragraph delimiter nroff macro (for "{"
X | and "}").
X | a <sp> preceded by a '\' indicates that the previous
X | char is a single letter macro.
X | ":set para=P\ bp" introduces '.P' and '.bp' as
X | paragraph delimiters.
X | furthermore completely empty lines and section
X | boundaries are paragraph boundaries too.
Xredraw | the screen remains up to date
Xreport=<*> | vi reports whenever e.g. a delete
X | or yank command affects <*> or more lines
Xro | readonly - the file is not to be changed
X | however, ":w!" will override this option
Xsect=<string> | sections - gives the section delimiters (for "[[" and
X | "]]"); see option 'para', however a '{' as first
X | char on a line also starts a section (C functions!)
Xsh=<string> | shell - which program is to be used for shell escapes
Xsw=<*> | shiftwidth - gives the swiftwidth (default sw=8)
Xsm | showmatch - whenever you append a ')', vi tries to
X | show its match by putting for a moment the cursor
X | onto it (also with { })
Xterse | short error messages
Xts=<*> | tabstop - the length of a <ht>;
X | warning: this is only IN the editor, outside of it
X | <ht>s have their normal length (default ts=8)
Xwa | writeany - no checks when writing (dangerous)
Xwarn | warn you when you try to quit without writing
Xwi=<*> | window - the number of lines vi is to show default
Xwm=<*> | wrapmargin - when in append mode vi automatically
X | puts a <lf> whenever there is a breakpoint (e.g. <sp>
X | or ',') within <wm> columns from the right margin
Xws | wrapscan - when searching, the end is considered
X | 'stuck' to the begin of the file
X
X:set option | turn option on
X:set no option | turn option off; no <sp> between "no" and the option
X:set option=value | give an option a value
X:set | show all non-default options and their values
X:set option? | show an option's value
X:set all | show all options and their values
X
+ END-OF-FILE vi.ref
chmod 'u=r,g=r,o=r' 'vi.ref'
set `wc -c 'vi.ref'`
count=$1
case $count in
16948) :;;
*) echo 'Bad character count in ''vi.ref' >&2
echo 'Count should be 16948' >&2
esac
exit 0
--
"Mom! Eric Newton broke the day! In 24 |Maarten Litmaath @ VU Amsterdam:
parts!" (Mike Schmitt in misc.misc) |maart@cs.vu.nl, mcvax!botter!maart