home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Black Box 4
/
BlackBox.cdr
/
editors
/
vi60a1.arj
/
VIHELP.TXT
< prev
next >
Wrap
Text File
|
1991-12-25
|
22KB
|
429 lines
SECTION A //////////////////////////////////////////////////////
/ COMMAND REFERENCE FOR OAK HILL VI AND PERSONAL VI* /
//////////////////////////////////////////////////////
Section
Code Section Topic Basic Command Examples
=============================================================================
A ..... Section Code Listing .. (This screen)
B ..... Legenda ............... Syntax notations
C ..... Vi Startup ............ vi file[s] vi +cmd file[s]
D ..... Moving Around ......... h j k l fx Fx tx Tx 1G
E ..... Searching ............. /pat/ ?pat? n N / ?
F ..... Adding New Text ....... i a o I A O p P
G ..... Deleting Text ......... dd d'a ndd D
H ..... Changing Text ......... c C s S
I ..... Remembering Text ...... yy y'a nyy Y
J ..... Other Commands ........ :fillp :sh
K ..... Write, Quit, Edit New . :w :e :n :tag ZZ
L ..... Map(!) and Abbrev ..... :map ;s :s/Sam/Bill/
M ..... Setting Options ....... :set noai :set wm
This reference does not show all commands and contains only brief
descriptions. Please see manual for details.
* Adapted from "Vi Reference" by Maarten Litmaath
SECTION B ///////////
/ Legenda /
///////////
default values : 1
<*> : `*' must not be taken literally
[*] : `*' is optional
^X : <ctrl>X
<sp> : space
<cr> : carriage return
<lf> : linefeed
<ht> : horizontal tab
<esc> : escape
<erase> : your erase character
<intr> : your interrupt character
<a-z> : an element in the range
N : number (`*' = allowed, `-' = not appropriate)
CHAR : char that is not <ht> or <sp>
WORD : word that is followed by <ht> or <sp> or <lf>
SECTION C //////////////
/ vi startup /
//////////////
vi [<files>] | Edit the files, start with the first page of
| the first file.
The editor can be initialized by a single 'colon' command in the
environment variable `EXINIT', which looks like:
EXINIT='<cmd>'
However, an unlimited list of initializations can also be put into a
file called EXRC. This list will override the EXINIT variable.
On-line initializations can be given with `vi +<cmd> file', e.g.:
vi +x file | The cursor will immediately jump to line x
SECTION D /////////////////
/ Moving Around /
/////////////////
N | Command | Meaning
---+--------------------+-----------------------------------------------
* | h | ^H | <*> chars to the left.
* | j | <*> lines downward.
* | l | <sp> | <*> chars to the right.
* | k | <*> lines upward.
* | $ | To the end of line <*> from the cursor.
- | ^ | To the first CHAR of the line.
* | - | To the first CHAR <*> lines higher.
* | + | <cr> | To the first CHAR <*> lines lower.
- | 0 | To the first char of the line.
* | | | To column <*>
* | f<char> | <*> <char>s to the right (find).
* | t<char> | Till before <*> <char>s to the right.
* | F<char> | <*> <char>s to the left.
* | T<char> | Till after <*> <char>s to the left.
* | ; | Repeat latest `f'|`t'|`F'|`T' <*> times.
* | , | Same as above but in opposite direction.
* | w | <*> words forward.
* | W | <*> WORDS forward.
* | b | <*> words backward.
* | B | <*> WORDS backward.
* | e | To the end of word <*> forward.
* | E | To the end of WORD <*> forward.
* | G | Go to line <*> (default EOF).
* | H | To line <*> from top of the screen (home).
* | L | To line <*> from bottom of the screen (last).
- | M | To the middle line of the screen.
* | ) | <*> sentences forward.
* | ( | <*> sentences backward.
* | } | <*> paragraphs forward.
* | { | <*> paragraphs backward.
- | `<a-z> | To the mark.
- | '<a-z> | To the first CHAR of the line with the mark.
- | `` | To the cursor position before the latest absolute
| jump (of which are examples `/' and `G').
- | '' | To the first CHAR of the line on which the cursor
| was placed before the latest absolute jump.
- | % | To the matching parenthesis or bracket
^G | Give file name, status, current line number
| and relative position.
^L | Refresh the screen in case of display corruption
[*]^E | Expose <*> more lines at bottom, cursor
| stays put (if possible).
[*]^Y | Expose <*> more lines at top, cursor
| stays put (if possible).
[*]^D | Scroll <*> lines downward
| (default the number of the previous scroll;
| initialization: half a page).
[*]^U | Scroll <*> lines upward
| (default the number of the previous scroll;
| initialization: half a page).
[*]^F | <*> pages forward.
[*]^B | <*> pages backward (in older versions `^B' only
| works without count).
[*]z<cr> | Put line <*> at the top of the window
| (default the current line).
[*]z+ | Put line <*> at the top of the window
| (default the first line of the next page).
[*]z- | Put line <*> at the bottom of the window
| (default the current line).
[*]z^ | Put line <*> at the bottom of the window
| (default the last line of the previous page).
[*]z. | Put line <*> in the centre of the window
| (default the current line).
SECTION E /////////////
/ Searching /
/////////////
- | /<string> | Jump to the next occurrence of <string>.
- | ?<string> | Jump to the previous occurrence of <string>.
- | n | Repeat latest `/' or `?' command
- | N | Same as above but search in opposite direction.
:ta <name> | Search in the tags file where <name> is
| defined (file, line), and go to it.
^] | Use the name under the cursor in a `:ta' command.
SECTION F ////////////////////////////////////
/ Adding New Text (end with <esc>) /
////////////////////////////////////
- | <esc> | Exit append mode, return to command mode
- | u | Undo the latest text change command
- | a | <*> times after the cursor.
- | A | <*> times at the end of line.
- | i | <*> times before the cursor (insert).
- | I | <*> times before the first CHAR of the line
- | o | On a new line below the current (open).
| The count is only useful on a slow terminal.
- | O | On a new line above the current.
| The count is only useful on a slow terminal.
* | >'a | Shift the lines from the current line to the
| line marked 'a' one shiftwidth to the right.
* | >> | Shift <*> lines one shiftwidth to the right.
- | ["<a-z>]p | Put the contents of the (default undo) buffer
| after the cursor.
| A buffer containing lines is put below
| the current line.
- | ["<a-z>]P | Put the contents of the (default undo) buffer
| <*> times before the cursor.
| A buffer containing lines is put only once,
| above the current line.
- | . | Repeat previous text change command.
| Special commands while in append mode:
^V | Deprive the next char of its special meaning
| (e.g. <esc>).
^D | One shiftwidth to the left.
^H | <backspace> | One char back.
^W | One word back.
SECTION G /////////////////
/ Deleting Text /
/////////////////
Everything deleted can be stored into a buffer. This is achieved by
putting a `"' and a letter <a-z> before the delete command. The
deleted text will be in the buffer with the used letter.
* | x | Delete <*> chars under and after the cursor.
* | X | Delete <*> chars before the cursor.
* | d<move> | From begin to endpoint of <*><move>.
* | dd | Delete <*> lines.
- | D | The rest of the line.
- | <'x | Shift the lines from the current line to the
| line marked 'x' one shiftwidth to the left.
* | << | Shift <*> lines one shiftwidth to the left.
* | . | Repeat latest command <*> times.
=== EXAMPLES ===
4dd Deletes 4 lines
d'a Deletes lines from current line to the one marked 'a'
de Deletes to end of current word
dE Deletes to end of current WORD
SECTION H //////////////////////////////////
/ Changing Text (end with <esc>) /
//////////////////////////////////
- | r<char> | Replace current char by <char> - no <esc>.
- | R | Overwrite the current line
* | s | Substitute <*> chars.
* | S | Substitute <*> lines.
* | c<move> | Change from begin to endpoint of <*><move>.
* | cc | Change <*> lines.
* | C | The rest of the line and <*> - 1 next lines.
- | ~ | Switch lower and upper case for current character
- | J | Join 2 lines
- | . | Repeat latest text change command
- | & | Repeat latest `ex' substitute command, e.g.
| `:s/wrong/good' for current line only
- | :[x,y]s/<p>/<r>/<f>| Substitute (on lines x through y) the pattern <p>
| (default the last pattern) with <r>. Useful
| flag <f> is `g' for `global' (i.e. change
| every non-overlapping occurrence of <p>)
SECTION I //////////////////////////////
/ Remembering Text (Yanking) /
//////////////////////////////
With yank commands you can put `"<a-z>' before the command, just as
with delete commands. Otherwise you only copy to the undo buffer.
The use of buffers <a-z> is THE way of copying text to another file;
see the `:e <file>' command.
* | y<move> | Yank from begin to endpoint of <*><move>.
* | yy | <*> lines.
* | Y | Same as above
- | m<a-z> | Mark cursor position with letter from 'a' to 'z'.
SECTION J //////////////////////////////////
/ Substitutions & Other Commands /
//////////////////////////////////
:sh | Execute a subshell, back to vi with <cr>
|
:fillp | Fill ("format") the text in the paragraph
| in which the cursor sits. A "paragraph"
| is a section of text delimited by blank
| lines or lines that begin with a period.
:rfillp | Same as above, but each sentence begins
| on a new line.
|
!<addr><cmd> | The shell executes <cmd>, with as standard
| input the lines delimited by the current
| line and the line <addr>. Typically <addr>
| is a line marked with an address like 'a.
:r <name> | Read the file <name> into the buffer.
SECTION K /////////////////////////////////////////////////
/ Writing, Editing Other Files, and Quitting Vi /
/////////////////////////////////////////////////
In `:' `ex' commands `%' denotes the current file, `#' is a synonym for
the alternate file (which normally is the previous file).
Marks can be used for line numbers too: '<a-z>.
In the `:w'|`:f'|`:cd'|`:e'|`:n' commands shell meta-characters can be
used.
:q | Quit vi, unless the buffer has been changed.
:q! | Quit vi without writing.
:w | Write the file.
:w <name> | Write to the file <name>.
:we <name> | Write current file and edit file <name>.
:w >> <name> | Append the buffer to the file <name>.
:w! <name> | Overwrite the file <name>.
:x,y w <name> | Write lines x through y to the file <name>.
:wq | Write the file and quit vi;
ZZ | Write if the buffer has been changed, and
| quit vi.
:x [<file>] | Same as above [but write to <file>].
:x! [<file>] | `:w![<file>]' and `:q'.
:f <name> | Set the current filename to <name>.
:e [+<cmd>] <file> | Edit another file without quitting vi - the
| buffers are not changed (except the undo
| buffer), so text can be copied from one file to
| another this way. [Execute the `ex' command
| <cmd> (default `$') when the new file has been
| read into the buffer.] <cmd> must contain no
| <sp> or <ht>. See `vi startup'.
:e! [+<cmd>] <file> | Same as above, without writing the current buffer.
^^ | Edit the alternate (normally the previous) file.
:rew | Rewind the argument list, edit the first file.
:rew! | Idem, without writing the current buffer.
:n [+<cmd>] [<files>] | Edit next file or specify a new argument list.
:n! [+<cmd>] [<files>] | Idem, without writing the current buffer.
:args | Give the argument list, with the current file
| between `[' and `]'.
SECTION L ////////////////////////////
/ Mapping and Abbreviation /
////////////////////////////
When mapping take a look at the options `to' and `remap' (below).
:map <string> <seq> | <string> is interpreted as <seq> as if the
| commands in <seq> had been entered from the
| keyboard
:map | Show all mappings.
:unmap <string> | Deprive <string> of its mapping.
|
:map! <string> <seq> | <string> is interpreted as if <seq> had been
| entered in input mode, that is, the
| characters in <string> will be instantly
| replaced by <seq>
:map! | Show all input mode mappings.
:unmap! <string> | Deprive <string> of its mapping (see `:unmap').
|
:ab <string> <seq> | Whenever in input mode <string> is preceded and
| followed by space or punctuation, <string>
| is replaced by <seq>.
:ab | Show all abbreviations.
:unab <string> | Do not consider <string> an abbreviation
| anymore (see `:unmap').
|
@<a-z> | Consider the contents of the named register a
| command, e.g.:
| o:s/wrong/good/<esc>"ayy
| Explanation:
| o - open a new line
| :s/wrong/good/ - this input text is an
| `ex' substitute command
| <esc> - finish the input
| "add - yank the line just
| created into register `a'
| Now you can type `@a' to replace `wrong'
| with `good' on the current line.
@@ | Repeat last register command.
SECTION M //////////////////////////////
/ The Most Important Options /
//////////////////////////////
:set | Show all options and their values.
:set all | Show all options and their values.
|
:set ai | autoindent - In append mode after a <cr> the
:set noai | cursor will move directly below the first
| CHAR on the previous line. However, if the
| option `lisp' is set, the cursor will align
| at the first argument to the last open list.
|
:set aw | autowrite - Write at every shell escape
:set noaw | noautowrite - do not write at every shell escape
|
:set beep | Audibly beeps when you goof
:set nobeep | Visually flashes "BEEP" when you goof
| (not on every terminal).
|
:set colors=[bright] foreground [on] background
| Sets screen colors. "foreground" & "background"
| may be black, red, green, yellow, blue,
| magenta, cyan, or white. The "bright" modifier
| is optional. Recommended selections are
| bright white on blue or bright yellow on
| yellow.
|
:set cursor=underscore | Set cursor to flashing underscore or flashing
:set cursor=box | box. Choosing "inbox" will produce underscore
:set cursor=inbox | in command mode and flashing box in input mode.
|
:set ic | ignorecase - No distinction between upper and
:set noic | lower cases when searching.
|
:set magic | If this option is set (default), the chars `.',
:set nomagic | `[' and `*' have special meanings within search
| and `ex' substitute commands. To deprive such
| a char of its special function it must be
| preceded by a `\'. If the option is turned off
| it's just the other way around. Meta-chars:
| ^<string> - <string> must begin the line
| <string>$ - <string> must end the line
| . - matches any char
| [a-z] - matches any char in the range
| [^a-z] - any char not in the range
| [<string>] - matches any char in <string>
| [^<string>] - any char not in <string>
| <char>* - 0 or more <char>s
:set nu | Show line numbers with each line
:set nonu | Do not show line numbers with each line
|
:set rmar=n | Set right margin for text filling.
|
:set sect=<string> | sections - Gives the section delimiters (for `[['
| and `]]'); see option `para'. A `{' beginning a
| line also starts a section (as in C functions).
:set ts=<*> | tabstop - The length of a <ht>; warning: this is
| only IN the editor, outside of it <ht>s have
| their normal length (default 8 positions).
:set wm=<*> | wrapmargin - In append mode vi automatically
| puts a <lf> whenever there is a <sp> or <ht>
| within <wm> columns from the right margin
| (0 = don't put a <lf> in the file, yet put it
| on the screen).
:set ws | wrapscan - When searching, wrap around from
| end of file back to the beginning
:set nows | do not wrap when searching
|