home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso
/
misc
/
volume37
/
vim
/
part20
< prev
next >
Wrap
Text File
|
1993-04-24
|
50KB
|
1,260 lines
Newsgroups: comp.sources.misc
From: mool@oce.nl (Bram Moolenaar)
Subject: v37i020: vim - Vi IMitation editor v1.27, Part20/24
Message-ID: <1993Apr25.013816.23275@sparky.imd.sterling.com>
X-Md4-Signature: 512b2a82e66cfeeb1df7f9f2842ad156
Date: Sun, 25 Apr 1993 01:38:16 GMT
Approved: kent@sparky.imd.sterling.com
Submitted-by: mool@oce.nl (Bram Moolenaar)
Posting-number: Volume 37, Issue 20
Archive-name: vim/part20
Environment: UNIX, AMIGA, MS-DOS
#! /bin/sh
# This is a shell archive. Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file". To overwrite existing
# files, type "sh file -c". You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g.. If this archive is complete, you
# will see the following message at the end:
# "End of archive 20 (of 23)."
# Contents: vim/doc/reference.doc2
# Wrapped by mool@oce-rd2 on Mon Apr 19 15:50:13 1993
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'vim/doc/reference.doc2' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/doc/reference.doc2'\"
else
echo shar: Extracting \"'vim/doc/reference.doc2'\" \(46054 characters\)
sed "s/^X//" >'vim/doc/reference.doc2' <<'END_OF_FILE'
X (inclusive).
X
X; Repeat latest f, t, F or T [cnt] times.
X
X, Repeat latest f, t, F or T in opposite direction
X [cnt] times.
X
XThese commands move the cursor to the specified column in the current line.
XThey stop at the first column and at the end of the line, except '$', which
Xmay move to one of the next lines.
X
X
X6.2 Up-down motions
X
Xk or
X<C_UP> or
XCTRL-P [cnt] lines upward (linewise).
X
Xj or
X<C_DOWN> or
XCTRL-J or
X<LF> or
XCTRL-N [cnt] lines downward (linewise).
X
X- <minus> [cnt] lines upward, on the first non-blank character
X (linewise).
X
X+ or
XCTRL-M or
X<CR> [cnt] lines downward, on the first non-blank
X character (linewise).
X
X_ <underscore> [cnt] - 1 lines downward, on the first non-blank
X character (linewise).
X
XG Goto line [cnt], default last line, on the first
X non-blank character (linewise).
X
X:[range] Set the cursor on the (last) specified line number
X (cannot be used with an operator).
X
X{cnt}% Go to {cnt} percentage in the file, column 1
X (linewise). To compute the new line number this
X formula is used: {cnt} * number-of-lines / 100. {not
X in Vi}
X
XThese commands move to the specified line. They stop when reaching the first
Xor the last line. The first two commands put the cursor in the same column
X(if possible) as it was after the last command that changed the column,
Xexcept after the '$' command, then the cursor will be put on the last
Xcharacter of the line.
X
X
X6.3 Word motions
X
X<SC_RIGHT> or
Xw [cnt] words forward (exclusive).
X
XW [cnt] WORDS forward (exclusive).
X
Xe Forward to the end of word [cnt] (inclusive).
X
XE Forward to the end of WORD [cnt] (inclusive).
X
X<SC_LEFT> or
Xb [cnt] words backward (exclusive).
X
XB [cnt] WORDS backward (exclusive).
X
XThese commands move over words or WORDS. A word consists of a sequence of
Xletters, digits and underscores, or a sequence of other non-blank
Xcharacters, separated with blank space. A WORD consists of a sequence of
Xnon-blank characters, separated with blank space. The end of a line is also
Xconsidered to be blank space. An empty line is also considered to be a word
Xand a WORD.
X
XSpecial case: "cw" and "cW" are treated like "ce" and "cE" if the cursor is
Xon a non-blank. This is because "cw" is interpreted as change-word, and a
Xword does not include the following blank space. {Vi: "cw" when on a blank
Xfollowed by other blanks changes only the first blank; this is probably a
Xbug, because "dw" deletes all the blanks}
X
X
X6.4 Text object motions
X
X( [cnt] sentences backward (exclusive).
X
X) [cnt] sentences forward (exclusive).
X
X{ [cnt] paragraphs backward (exclusive).
X
X} [cnt] paragraphs forward (exclusive).
X
X]] [cnt] sections forward, except when used after an
X operator, then [cnt] SECTIONS forward (linewise).
X
X][ [cnt] SECTIONS forward (linewise).
X
X[[ [cnt] sections backward (linewise).
X
X[] [cnt] SECTIONS backward (linewise).
X
XThese commands move over three kinds of text objects.
X
XA sentence is defined as ending at a '.', '!' or '?' followed by either the
Xend of a line, or by a space. {Vi: two spaces} Any number of closing ')',
X']', '"' and ''' characters my appear after the '.', '!' or '?' before the
Xspaces or end of line. A paragraph and section boundary is also a sentence
Xboundary.
X
XA paragraph begins after each empty line, and also at each of a set of
Xparagraph macros, specified by the pairs of characters in the 'paragraphs'
Xoption. The default is "IPLPPPQPP LIpplpipbp", which corresponds to the
Xmacros ".IP", ".LP", etc. (these are nroff macros, the dot must be in the
Xfirst column). A section boundary is also a paragraph boundary.
X
XA section begins after a form-feed in the first column, a '{' in the first
Xcolumn, and also at each of a set of section macros, specified by the pairs
Xof characters in the 'sections' option. The default is "SHNHH HUnhsh". A
XSECTION is the same as a section, except that a '}' replaces the '{'. This
Xis useful to find the end of C-language functions.
X
X
X6.5 Pattern searches
X
X/{pattern}[/] Search forward for the [cnt]'th occurrence of
X {pattern} (exclusive).
X
X/{pattern}/{offset} Search forward for the [cnt]'th occurrence of
X {pattern} and go {offset} lines up or down (see
X below). (linewise).
X
X/ Search forward for the [cnt]'th latest used pattern
X with latest used {offset}.
X
X//{offset} Search forward for the [cnt]'th latest used pattern
X with new {offset}. If {offset} is empty no offset is
X used.
X
X* Search forward for the [cnt]'th occurrence of the
X ident after or under the cursor (exclusive). {not in
X Vi}
X
X# Search backward for the [cnt]'th occurrence of the
X ident after or under the cursor (exclusive). {not in
X Vi}
X
X?{pattern}[?] Search backward for the [cnt]'th previous
X occurrence of {pattern} (exclusive).
X
X?{pattern}?{offset} Search backward for the [cnt]'th previous occurrence
X of {pattern} and go {offset} lines up or down (see
X below) (linewise).
X
X? Search backward for the [cnt]'th latest used pattern
X with latest used {offset}.
X
X??{offset} Search backward for the [cnt]'th latest used pattern
X with new {offset}. If {offset} is empty no offset is
X used.
X
Xn Repeat the latest '/' or '?' [cnt] times. {Vi: no
X count}
X
XN Repeat the latest '/' or '?' [cnt] times in opposite
X direction. {Vi: no count}
X
XCTRL-C Interrupt current (search) command.
X
XThese commands search for the specified pattern. With "/" and "?" an
Xadditional offset may be given. There are two types of offsets: line offsets
Xand character offsets. {the character offsets are not in Vi}
X
XThe offset gives the cursor positition relative to the found match:
X +[num] [num] lines downwards, in column 1
X -[num] [num] lines upwards, in column 1
X e[+num] [num] characters to the right of the end of the match
X e[-num] [num] characters to the left of the end of the match
X s[+num] [num] characters to the right of the start of the match
X s[-num] [num] characters to the left of the start of the match
X n not an offset: search without setting the current position
X of the cursor (used for the :tags command)
X
XIf [num] is omitted it is assumed to be zero.
X
XExamples:
X
Xpattern cursor position
X/test/+1 one line below "test", in column 1
X/test/e on the last t of "test"
X/test/s+2 on the "s" of "test"
X
XIf one of these commands is used after an operator, the characters between
Xthe cursor position before and after the search is affected. However, if a
Xline offset is given, the whole lines between the two cursor positions are
Xaffected.
X
XThe last used <pattern> and <offset> are remembered. They can be used to
Xrepeat the search, possibly in another direction or with another count. Note
Xthat only one <pattern> is remembered for all searches, including :s
X(substitute). Each time an empty <pattern> is given, the previously used
X<pattern> is used.
X
XIf the 'wrapscan' option is set (which is the default), searches wrap around
Xthe end of the buffer. If 'wrapscan' is not set, the backward search stops
Xat the beginning and the forward search stops at the end of the buffer. If
Xthe pattern was not found the error message "pattern not found" is given,
Xand the cursor will not be moved.
X
XPatterns may contain special characters, depending on the setting of the
X'magic' option. The '*' and '#' commands search for the identifier currently
Xunder the cursor. If there is no indentifier under the cursor, the first one
Xto the right is used. This identifier may only contain letters, digits and
Xunderscores. Note that if you type with ten fingers, the characters are easy
Xto remember: the '#' is under your left hand middle finger and the '*' is
Xunder your right hand middle finger.
X
XThe definition of a pattern:
X
X1. A pattern is one or more branches, separated by '\|'. It matches anything
X that matches one of the branches.
X
X2. A branch is one or more pieces, concatenated. It matches a match for the
X first, followed by a match for the second, etc.
X
X3. A piece is an atom, possibly followed by:
X magic nomagic
X * \* matches 0 or more of the preceding atom
X \+ \+ matches 1 or more of the preceding atom {not
X in Vi}
X \? \? matches 0 or 1 of the preceding atom {not in
X Vi}
X
X4. An atom can be:
X - One of these five:
X magic nomagic
X . \. matches any single character
X \< \< matches the beginning of a word
X \> \> matches the end of a word
X ^ ^ at beginning of pattern, matches start of
X line
X $ $ at end of pattern, matches end of line
X - A pattern enclosed by escaped parentheses (e.g. "\(^a\)").
X - A single character, with no special meaning, matches itself
X - A backslash followed by a single character, with no special meaning,
X matches the single character.
X - A range. This is a sequence of characters enclosed in '[]' with the
X 'magic' option, or enclosed in '\[]' with the 'nomagic' option. It
X normally matches any single character from the sequence. If the
X sequence begins with '^', it matches any single character NOT in the
X sequence. If two characters in the sequence are separated by '-', this
X is shorthand for the full list of ASCII characters between them (e.g.
X '[0-9]' matches any decimal digit). To include a literal ']' in the
X sequence, make it the first character (following a possible '^'). To
X include a literal '\-', make it the first or last character.
X
XIf the 'ignorecase' option is set, the case of letters is ignored.
X
X<NUL> characters in the file are stored as <LF> in memory. To match them use
X<LF>, which can be typed with CTRL_V CTRL_J. Note that the <NUL> character is
Xdisplayed as "^@".
X
XExamples:
X^beep( Probably the start of the C function "beep".
X
X[a-zA-Z]$ Any alphabetic character at the end of a line.
X
X\(^\|[^a-zA-Z0-9_]\)[a-zA-Z_]\+[a-zA-Z0-9_]*
X A C identifier (will stop in front of it).
X
X[.!?][])"']*\($\|[ ]\) A search pattern that finds the end of a sentence,
X with almost the same definition as the <)> command.
X
X
X
X6.6 Various motions
X
Xm<a-zA-Z> Set mark <a-zA-Z> at cursor position (does not move
X the cursor, this is not a motion command).
X
X:[range]mar[k] <a-zA-Z> Set mark <a-zA-Z> at last line number in [range],
X column 0. Default is cursor line.
X
X:[range]k<a-zA-Z> Same as :mark, but the space before the mark name can
X be omitted.
X
X'<a-z> To the first non-blank character on the line with
X mark <a-z> (linewise).
X
X'<A-Z> To the first non-blank character on the line with
X mark <A-Z> in the correct file (linewise when in
X same file, not a motion command when in other file).
X {not in Vi}
X
X`<a-z> To the mark <a-z> (exclusive).
X
X`<A-Z> To the mark <A-Z> in the correct file (exclusive
X when in same file, not a motion command when in
X other file). {not in Vi}
X
X:marks List the current marks (not a motion command). {not
X in Vi}
X
XA mark is not visible in any way. It is just a position in the file that is
Xremembered. Do not confuse marks with named registers, they are totally
Xunrelated.
X
XLowercase marks are only remembered as long as you stay in the current
Xfile. If you start editing another file, change a character in a line or
Xdelete a line that contains a mark, that mark is erased. Lowercase marks can
Xbe used in combination with operators. For example: "d't" deletes the lines
Xfrom the cursor position to mark a. Hint: Use mark <t> for Top, <b> for
XBottom, etc..
X
XUppercase marks include the file name. {Vi: no uppercase marks} You can use
Xthem to jump from file to file. You can only use an uppercase mark with
Xan operator if the mark is in the current file. As long as you stay in the
Xcurrent file the line number of the mark remains correct, even if you
Xinsert/delete lines. After changing files the line number may be wrong
X(keeping them correct would take too much time). To avoid this use a
X":marks" command before abandoning a file, this will update the line numbers
Xin the current file.
X
X
X'[ To the first non-blank character on the first line
X of the previously operated text or start of the last
X putted text. {not in Vi}
X
X`[ To the first character of the previously operated
X text or start of the last putted text. {not in Vi}
X
X'] To the first non-blank character on the last line of
X the previously operated text or end of the last
X putted text. {not in Vi}
X
X`] To the last character of the previously operated
X text or end of the last putted text. {not in Vi}
X
XAfter executing an operator the Cursor is put at the beginning of the text
Xthat was operated upon. After a put command ("p" or "P") the cursor is
Xsometimes placed at the first inserted line and somtimes on the last
Xinserted character. The four commands above put the cursor at either
Xend. Example: After yanking 10 lines you want to go to the last one of them:
X"10Y']". After inserting several lines with the "p" command you want to jump
Xto the lowest inserted line: "p']".
X
XNote: After deleting text, the start and end positions are the same, except
Xwhen using blockwise quoting. These commands do not work when no operator
Xor put command has been used yet in the current file. The position may be
Xincorrect after inserting text and ".p.
X
X
X'' To the first non-blank character of the line where
X the cursor was before the latest jump (linewise).
X
X`` To the position before latest jump (exclusive).
X
XA "jump" is one of the following commands: "'", "`", "G", "/", "?", "n",
X"N", "%", "(", ")", "[[", "]]", "{", "}", ":s", ":tag" and the commands that
Xstart editing a new file. If you make the cursor "jump" with one of these
Xcommands, the position of the cursor before the jump is remembered. You can
Xreturn to that position with the "''" and "``" command, unless the line
Xcontaining that position was changed or deleted.
X
XCTRL-O Go to [cnt] Older cursor position in jump list
X (not a motion command). {not in Vi}
X
XCTRL-I Go to [cnt] newer cursor position in jump list
X (not a motion command). {not in Vi}
X
X:jumps Print the jump list (not a motion command). {not in
X Vi}
X
XJumps are remembered in a jump list. With the CTRL-O and CTRL-I command you
Xcan go to cursor positions before older jumps, and back again. Thus you can
Xmove up and down the list.
X
XFor example, after three jump commands you have this jump list:
X
X jump line file
X 1 1 -current-
X 2 70 -current-
X 3 1154 -current-
X>
X
XYou are currently in line 1167. If you then use the CTRL-O command, the
Xcursor is put in line 1154. This results in:
X
X jump line file
X 1 1 -current-
X 2 70 -current-
X> 3 1154 -current-
X 4 1167 -current-
X
XThe pointer will be set at the last used jump position. The next CTRL-O
Xcommand will use the entry above it, the next CTRL-I command will use the
Xentry below it. If the pointer is below the last entry, this indicates that
Xyou did not use a CTRL-I or CTRL-O before. In this case the CTRL-O command
Xwill cause the cursor position to be added to the jump list, so you can get
Xback to the postition before the CTRL-O. In this case this is line 1167.
X
XWith more CTRL-O commands you will go to lines 70 and 1. If you use CTRL-I
Xyou can go back to 1154 and 1167 again.
X
XIf you use a jump command, the current line number is inserted at the end of
Xthe jump list. If you used CTRL-O or CTRL-I just before that, the same line
Xmay be in the list twice. This may be a bit strange. Just try it and look at
Xthe jump list with the :jumps command. Note that this behaviour is different
Xfrom the tag stack.
X
XAfter the CTRL-O command that got you into line 1154 you could give another
Xjump command (e.g. 'G'). The jump list would then become:
X
X jump line file
X 1 1 -current-
X 2 70 -current-
X 3 1154 -current-
X 4 1167 -current-
X 5 1154 -current-
X>
X
XAs long as you stay in the same file, the line numbers will be adjusted for
Xdeleted and inserted lines. If you go to another file the line numbers may
Xbe wrong (keeping them correct would take too much time). If you want to
Xavoid this use a :jumps command before changing files. This will update the
Xline numbers in the current file.
X
X% Find the next parenthesis or (curly/square) bracket
X on this line and go to its match (inclusive). No
X count is allowed.
X
XH To line [cnt] from top (Home) of screen (default:
X first line on the screen) on the first non-blank
X character (linewise).
X
XM To Middle line of screen, on the first non-blank
X character (linewise).
X
XL To line [cnt] from bottom of screen (default: Last
X line on the screen) on the first non-blank character
X (linewise).
X
X
X 7. Scrolling
X
XUpwards scrolling, window goes downwards:
X
XCTRL-E Window [cnt] lines downwards in the buffer ([cnt]
X lines Extra).
X
XCTRL-D Window [cnt] lines Downwards in the buffer (default:
X previous [cnt] or half a screen).
X
X<SC_DOWN> or
XCTRL-F Window [cnt] pages Forwards (downwards) in the
X buffer.
X
XDownwards scrolling, window goes upwards:
X
XCTRL-Y Window [cnt] lines upwards in the buffer.
X
XCTRL-U Window [cnt] lines Upwards in the buffer (default:
X previous [cnt] or half a screen).
X
X<SC_UP> or
XCTRL-B Window [cnt] pages Backwards (upwards) in the buffer.
X
Xz<CR> Redraw, line [cnt] at top of window (default cursor
X line).
X
Xz{height}<CR> Redraw, make window {height} lines tall (if the
X height is different from the number of lines for the
X current terminal, this may cause problems with
X screen updating).
X
Xz. Redraw, line [cnt] at center of window (default
X cursor line).
X
Xz- Redraw, line [cnt] at bottom of window (default
X cursor line).
X
XThese commands move the contents of the window. If the cursor position is
Xmoved off of the window, the cursor is moved onto the window. A page is the
Xnumber of lines in the window minus two. The mnemonics for these commands
Xmay be a bit confusing. Remember that the commands refer to moving the
Xwindow upwards or downwards in the buffer. But when the window moves upwards
Xin the buffer, the text in the window moves downwards on your screen.
X
X
X 8. Tags
X
X:ta[g][!] {ident} Jump to the definition of {ident}, using the
X information in the tags file. Put {ident} in the tag
X stack. See below for [!].
X
XCTRL-] ":ta" to the identifier under or after cursor. Put
X the identifier in the tag stack. {Vi: identifier
X after the cursor}
X
XCTRL-T Jump to [cnt] older entry in the tag stack (default
X 1). {not in Vi}
X
X:[count]po[p][!] Jump to [count] older entry in tag stack (default 1).
X See below for [!]. {not in Vi}
X
X:[count]ta[g][!] Jump to [count] newer entry in tag stack (default 1).
X See below for [!]. {not in Vi}
X
X:tags Show the contents of the tag stack. The active
X entry is marked with a '>'. {not in Vi}
X
XA tag is an identifier that appears in the "tags" file. It is a sort of label
Xthat can be jumped to. For example: In C programs each function name can be
Xused as a tag.
X
XWith the ":tag" command the cursor will be positioned on the tag. With the
XCTRL-] command, the identifier on which the cursor is standing is used as the
Xtag. If the cursor is not on an identifier, the first identifier rightwards
Xof the cursor is used.
X
XIf the tag is in the current file this will always work. Otherwise the
Xperformed actions depend on whether the current file was changed, whether a !
Xis added to the command and on the 'autowrite' option:
X
X tag in file autowrite
Xcurrent file changed ! option action
X-----------------------------------------------------------------------------
X yes x x x goto tag
X no no x x read other file, goto tag
X no yes yes x abondon current file, read other file, goto
X tag
X no yes no on write current file, read other file, goto
X tag
X no yes no off fail
X-----------------------------------------------------------------------------
X
X- If the tag is in the current file, the command will always work.
X- If the tag is in another file and the current file was not changed, the
X other file will be made the current file and read into the buffer.
X- If the tag is in another file, the current file was changed and a ! is
X added to the command, the changes to the current file are lost, the other
X file will be made the current file and read into the buffer.
X- If the tag is in another file, the current file was changed and the
X 'autowrite' option is set, the current file will be written, the other
X file will be made the current file and read into the buffer.
X- If the tag is in another file, the current file was changed and the
X 'autowrite' option is not set, the command will fail. If you want to save
X the changes, use the ":w" command and then use ":tag" without an argument.
X This works because the tag is put on the stack anyway. If you want loose
X the changes you can use the ":tag!" command.
X
XThe ":tag" command works very well for C programs. If you see a call to a
Xfunction and wonder what that function does, position the cursor inside of
Xthe function name and hit CTRL-]. This will bring you to the function
Xdefinition. An easy way back is with the CTRL-T command. Also read about the
Xtag stack below.
X
XA tags file can be created with the external command 'ctags'. It will
Xcontain a tag for each function. Some versions of 'ctags' will also make a
Xtag for each "#defined" macro.
X
XThe lines in the tags file should have this format:
X
X {tag}{separator}{filename}{separator}{command}
X
X{tag} the identifier
X{separator} a single <TAB> or space character
X{filename} the file that contains the definition of {tag}
X{command} the Ex command that positions the cursor on the tag (it can
X be any Ex command, but normally it is a search command like
X "/^main").
X
XThe 'tags' option is a list of file names separated by spaces. Each of these
Xfiles is searched for the tag. This can be used to use a different file than
Xthe default file "tags". It can also be used to access a common tags file.
XFor example:
X
X:set tags=tags\ s:commontags
X
XThe tag will first be searched for in the file "tags" in the current
Xdirectory. If it is not found there the file "s:commontags" will be searched
Xfor the tag. The backslash is required for the space to be included in the
Xstring option.
X
X
XThe tags that you use are remembered in the tag stack. You can print this
Xstack with the ":tags" command. The result looks like this:
X
X # TO tag FROM line in file
X 1 main 1 harddisk2:text/vim/test
X> 2 FuncA 58 -current-
X 3 FuncC 357 harddisk2:text/vim/src/amiga.c
X
XThis list shows the tags that you jumped to and the cursor position before that
Xjump. The older tags are at the top, the newer at the bottom.
X
XThe '>' points to the active entry. This is the tag that will be used by the
Xnext ":tag" command. The CTRL-T and ":pop" command will use the position
Xabove the active entry.
X
XThe line number and file name are remembered to be able to get back to where
Xyou were before the tag command. As long as you stay within one file the
Xline number will be correct, also when deleting/inserting lines. When you go
Xto another file the line number may not always be correct (keeping them
Xcorrect all the time would take too much time). To avoid this use the
X":tags" command before abondoning a file, which will update the line numbers
Xin the current file.
X
XYou can jump to previously used tags with several commands. Some examples:
X
X ":pop" or CTRL-T to position before previous tag
X {count}CTRL_T to position before {count} older tag
X ":tag" to newer tag
X ":0tag" to last used tag
X
XThe most obvious way to use this is while browsing through the call graph of
Xa program. Consider the following call graph:
X
X main ---> FuncA ---> FuncC
X ---> FuncB
X
X(Explanation: main calls FuncA and FuncB; FuncA calls FuncC).
XYou can get from main to FuncA by using CTRL-] on the call to FuncA. Then
Xyou can CTRL-] to get to FuncC. If you now want to go back to main you can
Xuse CTRL-T twice. Then you can CTRL-] to FuncB.
X
XIf you issue a ":ta {ident}" or CTRL-] command, this tag is inserted at the
Xbottom of the stack. If the stack was full (it can hold upto 20 entries), the
Xoldest entry is deleted and the older entries shift one position up (their
Xindex number is decremented by one). If the last used entry was not at the
Xbottom, the entries below the last used one are moved to the top. This means
Xthat an old branch in the call graph is not lost, but moved to another place
Xon the tag stack. The stack above would change to:
X
X # TO tag FROM line in file
X 1 FuncA 58 harddisk2:text/vim/src/main.c
X 2 FuncC 357 harddisk2:text/vim/src/amiga.c
X 3 main 1 harddisk2:text/vim/test
X 4 FuncB 59 harddisk2:text/vim/src/main.c
X>
X
XIn the call graph example: You can use this to go back from FuncB to FuncC
Xby hitting CTRL-T twice. This may be a bit strange. Use the :tags command to
Xfind out what will happen with CTRL-T commands.
X
X
X 9. Inserting text
X
Xa Append text after the cursor [cnt] times.
X
XA Append text at the end of the line [cnt] times.
X
Xi Insert text before the cursor [cnt] times.
X
XI Insert text before the first CHAR on the line [cnt]
X times.
X
Xo Begin a new line below the cursor and insert text,
X repeat [cnt] times. {Vi: blank [cnt] screen lines}
X
XO Begin a new line above the cursor and insert text,
X repeat [cnt] times. {Vi: blank [cnt] screen lines}
X
XThese commands are used to start inserting text. They can be undone and
Xrepeated. You can end insert mode with <ESC>. See the section "Insert and
Xreplace mode" for the other special characters in insert mode. The effect of
X[cnt] takes place after insert mode is exited.
X
X:r[ead] {name} Insert the file {name} below the cursor.
X
X:{range}r[ead] {name} Insert the file {name} below the specified line.
X
X:r[ead]!{cmd} Execute {cmd} and insert its standard output below
X the cursor.
X
XThese commands insert the contents of a file, or the output of a command,
Xinto the buffer. They can be undone. They cannot be repeated with the "."
Xcommand. They work on a line basis, insertion starts below the line in which
Xthe cursor is, or below the specified line. To insert text above the first
Xline use the command ":0r {name}".
X
X
X 10. Deleting text
X
X["x]x Delete [cnt] characters under and after the cursor
X [into register x] (not linewise).
X
X["x]X Delete [cnt] characters before the cursor [into
X register x] (not linewise).
X
X["x]d{motion} Delete text that is moved over [into register x].
X
X["x]dd Delete [cnt] lines [into register x] (linewise).
X
X["x]D Delete the characters under the cursor until the end
X of the line and [cnt]-1 more lines [into register
X x]; synonym for d$ (not linewise).
X
X{quote}["x]x or
X{quote}["x]d Delete the quoted text [into register x] (see the
X chapter on quoting). {not in Vi}
X
X{quote}["x]X or
X{quote}["x]D Delete the quoted lines [into register x] (see the
X chapter on quoting). {not in Vi}
X
X:[range]d[elete] [x] Delete [range] lines (default: current line) [into
X register x].
X
X:[range]d[elete] [x] {count}
X Delete {count} lines, starting with [range] (default:
X current line, see 4.4.3) [into register x].
X
XThese commands delete text. They can be repeated (except ":d") and undone.
XUse quoting to delete blocks of text. See "copying" for an explanation of
Xregisters.
X
X
XJ Join [cnt] lines, with a minimum of two lines.
X
X{quote}J Join the quoted lines, with a minimum of two lines.
X {not in Vi}
X
X:[range]j[oin][!] Join [range] lines. Same as 'J', except when [!] is
X given, then no spaces will be inserted or deleted.
X
X:[range]j[oin][!] {count}
X Join {count} lines, starting with [range] (default:
X current line, see 4.4.3). Same as 'J', except when
X [!] is given, then no spaces will be inserted or
X deleted.
X
XThese commands delete the newline between lines. This has the effect of
Xjoining them into one line. They can be repeated (except ":j") and undone.
X
XOne space is inserted in place of the <NL>, unless the line ended with a
Xspace, <TAB> or the next line started with a ')'. If the next line has
Xleading blank space it is deleted first. If the 'joinspaces' option is set,
Xtwo spaces are inserted after a period.
X
X
X 11. Changing text
X
XThe following commands can be used to change text, that is delete some text
Xand insert something else, with one command. They can all be undone. The
Xnon-Ex commands can be repeated with the "." command.
X
X
X11.1 Delete and insert
X
XR Enter replace mode: Each character you type replaces
X an existing character, starting with the character
X under the cursor. Repeat the entered text [cnt]-1
X times.
X
X["x]c{motion} Delete {motion} text [into register x] and start
X insert.
X
X["x]cc Delete [cnt] lines [into register x] and start insert
X (linewise).
X
X["x]C Delete from the cursor position to the end of the
X line and [cnt]-1 more lines [into register x], and
X start insert. Synonym for c$ (not linewise).
X
X["x]s Delete [cnt] characters [into register x] and start
X insert (s stands for Substitute). Synonym for "cl"
X (not linewise).
X
X["x]S Delete [cnt] lines [into register x] and start
X insert. Synonym for "^cc" with 'autoindent' option
X or "0cc" with 'noautoindent' option (not linewise).
X
X{quote}["x]c or
X{quote}["x]r or
X{quote}["x]s Delete the quoted text [into register x] and start
X insert (see the chapter on quoting). {not in Vi}
X
X{quote}["x]C or
X{quote}["x]R or
X{quote}["x]S Delete the quoted lines [into register x] and start
X insert (see the chapter on quoting). {not in Vi}
X
XYou can end insert and replace mode with <ESC>. See the section "Insert and
Xreplace mode" for the other special characters in these modes. The effect of
X[cnt] takes place after insert or replace mode is exited. {Vi: does not
Xdirectly delete the text, but puts a '$' at the last deleted character}
XSee "copying" for an explanation of registers.
X
XReplace mode is just like insert mode, except that for every character you
Xenter, one character is deleted. If the end of a line is reached, further
Xcharacters are appended (just like insert mode). In replace mode the
Xbackspace key only moves the cursor positition, no characters are deleted,
Xunless the 'repdel' option is set (see section "insert and replace mode").
X
XSpecial case: "cw" and "cW" are treated like "ce" and "cE" if the cursor is
Xon a non-blank. This is because "cw" is interpreted as change-word, and a
Xword does not include the following blank space. {Vi: "cw" when on a blank
Xfollowed by other blanks changes only the first blank; this is probably a
Xbug, because "dw" deletes all the blanks}
X
X
X11.2 Simple changes
X
Xr<char> Replace [cnt] characters by <char>.
X
X~ 'notildeop' option: switch case of [cnt] characters
X under the cursor and move the cursor [cnt]
X characters to the right. {Vi: no count}
X
X~{motion} 'tildeop' option: switch case of {motion} text. {Vi:
X tilde cannot be used as an operator}
X
X{quote}~ switch case of quoted text (see the chapter on
X quoting). {not in Vi}
X
X{quote}u Make quoted text uppercase (see the chapter on
X quoting). {not in Vi}
X
X{quote}U Make quoted text lowercase (see the chapter on
X quoting). {not in Vi}
X
XCTRL-A Add [cnt] to the number at or after the cursor. {not
X in Vi}
X
XCTRL-S Subtract [cnt] from the number at or after the
X cursor. {not in Vi}
X
XThe CTRL-A and CTRL-S commands work for (signed) decimal numbers and
Xunsigned octal and hexadecimal numbers. Numbers starting with '0x' or '0X'
Xare assumed to be hexadecimal. To decide whether the hexadecimal number
Xshould be printed uppercase or not, the case of the rightmost letter in the
Xnumber is considered. If there is no letter in the current number, the
Xpreviously detected case is used. Numbers starting with a '0' are considered
Xto be octal. Other numbers are decimal and may be preceded with a minus
Xsign. If the cursor is on a number, that one will be used. Otherwise the
Xnumber right of the cursor will be used.
X
XThe CTRL-A command is very useful in a macro. Example: How to make a
Xnumbered list.
X
X1. Make the first entry. The entry should start with a number.
X2. Start recording: "va".
X3. Yank the entry into a buffer: "Y".
X4. Put a copy of the entry below the first one: "p".
X5. Increment the number: CTRL-A.
X6. Stop recording: "v".
X7. Repeat all this with "<count>@a".
X
X
X<{motion} Shift the {motion} lines one shiftwidth leftwards.
X
X<< Shift [cnt] lines one shiftwidth leftwards.
X
X{quote}< Shift the quoted lines one shiftwidth leftwards (see
X the chapter on quoting). {not in Vi}
X
X>{motion} Shift {motion} lines one shiftwidth rightwards.
X
X>> Shift [cnt] lines one shiftwidth rightwards.
X
X{quote}> Shift the quoted lines one shiftwidth rightwards
X (see the chapter on quoting). {not in Vi}
X
X:[range]< Shift [range] lines left.
X
X:[range]< {count} Shift {count} lines left, starting with [range]
X (default current line, see 4.4.3).
X
X:[range]> Shift {count} [range] lines right.
X
X:[range]> {count} Shift {count} lines right, starting with [range]
X (default current line, see 4.4.3).
X
XThe ">" and "<" commands are handy for changing the indent within programs.
XThe size of the blank space which is inserted or deleted can be set with the
X'shiftwidth' option. Normally the 'shiftwidth' option is set to 8, but you
Xcan set it to e.g. 3 to make smaller indents. The shift leftwards stops when
Xthere is no indent. The shift right does not do anything with empty lines.
XIf the 'shiftround' option is set, the indent is rounded to a multiple of
X'shiftwidth'.
X
XV{motion} Format the lines that were moved over. The length of
X each line will be restricted to the width set with
X the 'textwidth' option. If you did not set the
X 'textwidth' option, all lines will be joined
X together. If the 'autoindent' option is set, use the
X indent of the first line. {not in Vi}
X
X
X11.3 Complex changes
X
X!{motion}{filter} Filter {motion} text through the external program
X {filter}.
X
X!!{filter} Filter [cnt] lines through the external program
X {filter}.
X
X{quote}!{filter} Filter the quoted lines through the external program
X {filter} (see the chapter on quoting). {not in Vi}
X
X:{range}![!]{filter} [!][arg]
X Filter {range} lines through the external program
X {filter}. The optional bangs are replaced with the
X latest given command. The optional [arg] is appended.
X
X={motion} Filter {motion} lines through the external program
X given with the 'equalprg' option (default:
X "indent"). {Vi: when 'lisp' option is set, autoindent
X {motion} lines}
X
X== Filter [cnt] lines through the external program given
X with the 'equalprg' option (default: indent). {not
X in Vi}
X
X{quote}= Filter the quoted lines through the external program
X given with the 'equalprg' option (default: indent)
X (see the chapter on quoting). {not in Vi}
X
XA filter is a program that accepts text at standard input, changes it in some
Xway, and sends it to standard output. The commands above can be used to send
Xsome text through a filter. An example of a filter is "sort", which sorts
Xlines alphabetically. The "indent" program is used to pretty indent C
Xprograms (you need a version of indent that works like a filter, not all
Xversions do that). The shell, given with the 'shell' option, is used to
Xexecute the command (See also the 'shelltype' option).
XThe filter commands can be redone with '.'.
X
X:[range]s[ubstitute]/{pattern}/{string}/[g][c] [count]
X For each line in [range] replace the first occurrence
X of {pattern} by {string}. With option [g] all
X occurrences in the line are replaced. With option
X [c] each replace has to be confirmed (<y> to
X replace, <q> to quit replacing, anything else to
X skip). With [count] that many lines are are
X searched, starting with the last line number in
X [range] (default current line, see 4.4.3).
X
X:[range]s[ubstitute] [g][c] [count]
X Repeat last :substitute with new options and possibly
X on other lines.
X
X:[range]&[/{pattern}/{string}/][g][c] [count]
X Same as for :substitute.
X
X& Synonym for ":s".
X
XIf the {pattern} for the substitute command is empty, the previously given
Xpattern is used (from any search, including '/' and ":g").
X
XFor the definition of a pattern see 6.5, "Pattern searches".
X
XSome characters in {string} have a special meaning:
X
Xmagic nomagic action
X & \& replaced by the whole matched pattern
X \& & replaced by &
X \0 replaced by the whole matched pattern
X \1 replaced by the matched pattern in the first pair of ()
X \2 replaced by the matched pattern in the second pair of ()
X .. ..
X \9 replaced by the matched pattern in the ninth pair of ()
X ~ \~ replaced by the {string} of the previous substitute
X \~ ~ replaced by ~
X \u next character made uppercase
X \U following characters made uppercase
X \l next character made uppercase
X \L following characters made uppercase
X \e end of /u, /U, /l and /L
X \E end of /u, /U, /l and /L
X
XExamples:
X:s/a\|b/xxx\0xxx/g modifies "a b" in "xxxaxxx xxxbxxx"
X:s/\([abc]\)\([efg]\)/\2\1/g modifies "af fa bg" in "fa fa gb"
X
XWhen using parentheses in combination with '|', like in \([ab]\)\|\([cd]\),
Xeither the first or second pattern in parentheses did not match, so either
X\1 or \2 is empty. Example:
X:s/\([ab]\)\|\([cd]\)/\1x/g modifies "a b c d" in "ax bx x x"
X
X
X 12. Copying and moving text
X
X"<a-zA-Z0-9.> Use register <a-zA-Z0-9.> for next delete, yank or put
X (uppercase to append) (<.> only works with put).
X
X:di[splay] Display the contents of numbered and named registers.
X {Vi: no such command}
X
X["x]y{motion} Yank {motion} text [into register x].
X
X["x]yy Yank [cnt] lines [into register x] (linewise).
X
X["x]Y With 'noyankendofline' option: yank [cnt] lines
X [into register x] (synonym for yy, linewise); with
X 'yankendofline' option: yank until end of line
X (synonym for y$, not linewise).
X
X{quote}["x]y Yank the quoted text [into register x] (see the
X chapter on quoting). {not in Vi}
X
X{quote}["x]Y Yank the quoted lines [into register x] (see the
X chapter on quoting). {not in Vi}
X
X:[range]y[ank] [x] Yank [range] lines [into register x].
X
X:[range]y[ank] [x] {count}
X Yank {count} lines, starting with last line number
X in [range] (default: current line, see 4.4.3), [into
X register x].
X
X["x]p Put the text [from register x] after the cursor [cnt]
X times. {Vi: no count}
X
X["x]P Put the text [from register x] before the cursor
X [cnt] times. {Vi: no count}
X
X:[line]pu[t] [x] Put the text [from register x] after [line] (default
X current line).
X
X:[line]pu[t]! [x] Put the text [from register x] before [line] (default
X current line).
X
XThese commands can be used to copy text from one place to another. This is
Xdone by first getting the text into a register with a yank, delete or change
Xcommand. The register can then be inserted with a put command. All registers
Xare kept when changing files. Thus you can also use this to move text from
Xone file to another (the CTRL-^ command is a quick way to toggle between two
Xfiles).
X
XThe put commands can be repeated (except for :put) and undone. If the
Xcommand that was used to get the text into the register was linewise, the
Xtext will be inserted below or above the line where the cursor is. Otherwise
Xthe text will be inserted before or after the cursor. With the ":put"
Xcommand the text will always be inserted in the next line. You can exchange
Xtwo characters with the command sequence "xp". You can exchange two lines
Xwith the command sequence "ddp". The "']" or "`]" command can be used after
Xthe put command to move the cursor to the end of the inserted text, "'[" or
X"`[" to move the cursor to the start.
X
XIf the command that was used to get the text into the register used
Xblockwise quoting, the block of text will be inserted before ('P') or after
X('p') the cursor column, in the current and next lines. Vim will make the
Xwhole block of text start in the same column. Thus the inserted text looks
Xthe same as when it was yanked or deleted. Some <TAB> characters may be
Xreplaced by spaces to make this happen. However, if the width of the block
Xis not a multiple of a <TAB> width and the text after the inserted block
Xcontains <TAB>s, that text may be misaligned.
X
XThere are three types of registers: 10 numbered registers, 26 named
Xregisters and one insert register.
X The numbered registers are filled with yank and delete commands.
XNumbered register "0" is filled with the last yank command, unless another
Xregister was specified with ["x]. Numbered register "1" is filled with the
Xtext that was deleted by each delete or change command, unless another
Xregister was specified. The contents of register "1" is put in "2", "2" in
X"3", and so forth. The contents of register "9" is lost. {Vi: numbered
Xregister contents is lost when changing files; register 0 does not exist}
X The named registers are only filled when you say so. They are named
X'a' to 'z' normally. If you use an uppercase letter, the same registers as
Xwith the lower case letter is used, but the text is appended to the previous
Xregister contents. With a lower case letter the previous contents is lost.
X The insert register "." contains the last inserted text. It can only
Xbe used with the commands 'p', 'P' and ':put'.
X
XIf you use a put command without specifying a register, the register that
Xwas last written to is used. If you are confused, use the ":dis" command to
Xfind out what will be put.
X
XThe next three commands always work on whole lines.
X
X:[range]co[py] {address}
X Copy the lines given by [range] to below the line
X given by {address}.
X
X:t Synonym for copy.
X
X:[range]m[ove] {address}
X Move the lines given by [range] to below the line
X given by {address}.
X
X
X 13. Quoting
X
XQuoting is a flexible and easy way to select a piece of text for an
Xoperator. It is the only way to select a block of text.
X
Xq start/stop quoting per character. {not in Vi}
X
XQ start/stop quoting linewise. {not in Vi}
X
XCTRL-Q start/stop quoting blockwise. {not in Vi}
X
Xo go to Other end of quoted text: The current cursor
X position becomes the start of the quoted text and
X the cursor is moved to the Other end of the quoted
X text. {not in Vi}
X
XTo apply an operator on a piece of text:
X 1. mark the start of the text with 'q', 'Q' or CTRL-Q
X The character under the cursor will be used as the start.
X 2. move to the end of the text
X The text from the start of the quoting up to and including
X the character under the cursor is highlighted.
X 3. hit an operator
X The highlighted characters will be operated upon.
X
XThe quoted text includes the character under the cursor. Vim tries to invert
Xthe cursor, but on some terminals the inverted cursor looks strange or
Xcannot been seen at all.
X
XWith 'q' the text before the start positition and after the end position will
Xnot be highlighted. However, All uppercase and non-alpha operators, except
X'~', will work on whole lines anyway. See the list of operators below.
X
XWith CTRL-Q (blockwise quoting) the quoted text will be a rectangle between
Xstart position and the cursor. However, some operators work on whole lines
Xanyway (see the list below). The change and substitute operators will delete
Xthe quoted text and then start insertion at the top left position.
X
XWhen the '$' command is used with blockwise quoting, the right end of the
Xquoted text will be determined by the longest quoted line. This stops when a
Xmotion command is used that does not move straight up or down.
X
XIf 'q', 'Q', CTRL-Q or ESC is typed while quoting, the quoting stops and no
Xtext is affected. If you hit CTRL-Z quoting stops and the editor is
Xsuspended or a new shell is started.
X
XFor moving the end of the block many commands can be used, but you cannot
Xuse Ex commands, commands that make changes or abandon the file. Commands
X(starting with) ".pPiIaAO&", CTRL_^, "ZZ", CTRL-], CTRL-T, CTRL-R, CTRL-I
Xand CTRL-O. If you try to use one of these commands a beep is given and
Xquoting continues.
X
XThe operators that can be used are:
X ~ switch case
X d delete
X c change
X y yank
X > shift right (1)
X < shift left (1)
X ! filter through external command (1)
X = filter through 'equalprg' option command (1)
X V format lines to 'textwidth' length (1)
X
XAdditionally the following commands can be used:
X : start ex command for quoted lines (1)
X r change
X s change
X C change (2)
X R change (2)
X S change (2)
X x delete
X D delete (2)
X X delete (2)
X Y yank (2)
X J join (1)
X u make uppercase
X U make lowercase
X
X(1): always whole lines
X(2): whole lines when not using CTRL-Q
X
XIf you want to give a buffer name using the '"' command, do this just before
Xtyping the operator character.
X
XWhen repeating a quoted operator, the operator will be applied to the same
Xamount of text as the last time:
X- Linewise quoting: The same number of lines.
X- Blockwise quoting: The same number of lines and columns.
X- Normal quoting within one line: The same number of characters.
X- Normal quoting with several lines: The same number of lines, in the last
X line the same number of characters as in the last line the last time.
XThe start of the text is the Cursor position. If the '$' command was used as
Xone of the last commands to extend the quoted text, the repeating will be
Xapplied upto the rightmost column of the longest line.
X
X
X 14. Various commands
X
XCTRL-L Clear and redraw the screen.
X
XCTRL-Z On Unix systems: Suspend Vim. On other systems:
X start a new shell (like ":sh").
X
X<HELP> or
X:h[elp] Show the help file page by page. The help file name
X can be set with the 'helpfile' option. {Vi: no help}
X
X<DEL> When entering a number: remove the last digit.
X
X:[range]p[rint] Print [range] lines (default current line).
X
X:[range]p[rint] {count}
X Print {count} lines, starting with [range] (default
X current line, see 4.4.3).
X
X:= Print the line number.
X
X:sh[ell] Escape to a shell (name from 'shell' option).
END_OF_FILE
if test 46054 -ne `wc -c <'vim/doc/reference.doc2'`; then
echo shar: \"'vim/doc/reference.doc2'\" unpacked with wrong size!
fi
# end of 'vim/doc/reference.doc2'
fi
echo shar: End of archive 20 \(of 23\).
cp /dev/null ark20isdone
MISSING=""
for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 ; do
if test ! -f ark${I}isdone ; then
MISSING="${MISSING} ${I}"
fi
done
if test "${MISSING}" = "" ; then
echo You have unpacked all 23 archives.
rm -f ark[1-9]isdone ark[1-9][0-9]isdone
else
echo You still need to unpack the following archives:
echo " " ${MISSING}
fi
## End of shell archive.
exit 0
-------------8<----------------8<----------------8<---------------8<--------
Bram Moolenaar | DISCLAIMER: This note does not
Oce Nederland B.V., Research & Development | necessarily represent the position
p.o. box 101, 5900 MA Venlo | of Oce-Nederland B.V. Therefore
The Netherlands phone +31 77 594077 | no liability or responsibility for
UUCP: mool@oce.nl fax +31 77 595450 | whatever will be accepted.
exit 0 # Just in case...