home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-12-22 | 46.7 KB | 1,166 lines |
- Newsgroups: comp.sources.misc
- From: mool@oce.nl (Bram Moolenaar)
- Subject: v41i071: vim - Vi IMitation editor, v2.0, Part21/25
- Message-ID: <1993Dec21.172817.2085@sparky.sterling.com>
- X-Md4-Signature: 5da429366eda39f64256652cb8cc63bb
- Keywords: utility, editor, vi, vim
- Sender: kent@sparky.sterling.com (Kent Landfield)
- Organization: Sterling Software
- Date: Tue, 21 Dec 1993 17:28:17 GMT
- Approved: kent@sparky.sterling.com
-
- Submitted-by: mool@oce.nl (Bram Moolenaar)
- Posting-number: Volume 41, Issue 71
- Archive-name: vim/part21
- Environment: UNIX, AMIGA, MS-DOS
- Supersedes: vim: Volume 37, Issue 1-24
-
- #! /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 21 (of 25)."
- # Contents: vim/doc/reference.do3
- # Wrapped by mool@oce-rd2 on Wed Dec 15 09:50:08 1993
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f 'vim/doc/reference.do3' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'vim/doc/reference.do3'\"
- else
- echo shar: Extracting \"'vim/doc/reference.do3'\" \(44166 characters\)
- sed "s/^X//" >'vim/doc/reference.do3' <<'END_OF_FILE'
- 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 to lose
- 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} one or more <TAB> or space characters
- 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 abandoning 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 up to 20 entries),
- Xthe oldest entry is deleted and the older entries shift one position up
- X(their index number is decremented by one). If the last used entry was not
- Xat the bottom, the entries below the last used one are moved to the top.
- XThis means that an old branch in the call graph is not lost, but moved to
- Xanother place on 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
- XThe following commands can be used to insert new text into the buffer. They
- Xcan all be undone. The non-Ex commands can be repeated with the "." command.
- X
- Xa Append text after the cursor [count] times.
- X
- XA Append text at the end of the line [count] times.
- X
- Xi Insert text before the cursor [count] times.
- X
- XI Insert text before the first CHAR on the line
- X [count] times.
- X
- Xo Begin a new line below the cursor and insert text,
- X repeat [count] times. {Vi: blank [count] screen
- X lines}
- X
- XO Begin a new line above the cursor and insert text,
- X repeat [count] times. {Vi: blank [count] screen
- X 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[count] 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
- XThe <LF> character is recognized as end-of-line marker. If the 'textmode'
- Xoption is set, a <CR> in front of an <LF> is ignored. The 'textmode' option
- Xis default on for MSDOS.
- X
- XIf the 'textauto' option is set Vim tries to recognize the type of
- Xend-of-line marker (see 5.2 how this is done). However, the 'textmode'
- Xoption will not be changed. Only while reading one file the text mode is
- Xused or not.
- X
- XOn non-MSDOS systems the message "[textmode]" is shown if a file is read in
- Xtext mode, to remind you that something unusual is done. On MSDOS the
- Xmessage "[notextmode]" is shown if a file is read without text mode.
- X
- X
- X 10. Deleting text
- X
- X["x]x Delete [count] characters under and after the cursor
- X [into register x] (not linewise).
- X
- X["x]X Delete [count] 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 See below for exception.
- X
- X["x]dd Delete [count] lines [into register x] (linewise).
- X
- X["x]D Delete the characters under the cursor until the end
- X of the line and [count]-1 more lines [into register
- X x]; synonym for d$ (not linewise).
- X
- X{visual}["x]x or
- X{visual}["x]d Delete the highlighted text [into register x] (see
- X the chapter on Visual mode). {not in Vi}
- X
- X{visual}["x]X or
- X{visual}["x]D Delete the highlighted lines [into register x] (see
- X the chapter on Visual mode). {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]
- X (default: current line, see 4.4.3) [into register
- X x].
- X
- XThese commands delete text. They can be repeated with the "." command
- X(except ":d") and undone. Use Visual mode to delete blocks of text. See
- X"copying" for an explanation of registers.
- X
- XAn exception for the d{motion} command: If the motion is not linewise, the
- Xstart and end of the motion are not in the same line and before the start
- Xand after the end are only blanks, the delete becomes linewise. This means
- Xthat the blank line that would remain is also deleted.
- X
- X
- XJ Join [count] lines, with a minimum of two lines.
- X
- X{visual}J Join the highlighted lines, with a minimum of two
- X lines. {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 <LF>, unless the line ended with a
- Xspace, <TAB> or the next line started with a <)>. If the next line has
- Xleading white 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 [count]-1
- X times.
- X
- X["x]c{motion} Delete {motion} text [into register x] and start
- X insert.
- X
- X["x]cc Delete [count] lines [into register x] and start
- X insert (linewise).
- X
- X["x]C Delete from the cursor position to the end of the
- X line and [count]-1 more lines [into register x], and
- X start insert. Synonym for c$ (not linewise).
- X
- X["x]s Delete [count] characters [into register x] and start
- X insert (s stands for Substitute). Synonym for "cl"
- X (not linewise).
- X
- X["x]S Delete [count] lines [into register x] and start
- X insert. Synonym for "^cc" with 'autoindent' option
- X or "0cc" with 'noautoindent' option (not linewise).
- X
- X{visual}["x]c or
- X{visual}["x]r or
- X{visual}["x]s Delete the highlighted text [into register x] and
- X start insert (see the chapter on Visual mode). {not
- X in Vi}
- X
- X{visual}["x]C or
- X{visual}["x]R or
- X{visual}["x]S Delete the highlighted lines [into register x] and
- X start insert (see the chapter on Visual mode). {not
- X 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[count] 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 and moving text" 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 restores the original text (if there was any) (see section
- X"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 white 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 the character under the cursor by <char>. If
- X <char> is a <CR> or <LF> the character will be
- X replaced by a line break. If a [count] is given that
- X many characters will be replaced by [count] <char>s
- X or line breaks {Vi: "5r<CR>" replaces five
- X characters with a single line break}
- X
- X~ 'notildeop' option: switch case of the character
- X under the cursor and move the cursor to the right.
- X If a [count] is given do that many characters {Vi:
- X no count}
- X
- X~{motion} 'tildeop' option: switch case of {motion} text. {Vi:
- X tilde cannot be used as an operator}
- X
- X{visual}~ switch case of highlighted text (see the chapter on
- X Visual mode). {not in Vi}
- X
- X{visual}U Make highlighted text uppercase (see the chapter on
- X Visual mode). {not in Vi}
- X
- X{visual}u Make highlighted text lowercase (see the chapter on
- X Visual mode). {not in Vi}
- X
- XCTRL-A Add [count] to the number at or after the cursor.
- X {not in Vi}
- X
- XCTRL-S Subtract [count] from the number at or after the
- X cursor. If your terminal has problems with CTRL-S
- X read unix.doc. {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. Create the first entry. The entry should start with a number.
- X2. qa - start recording into buffer <a>
- X3. Y - yank the entry
- X4. p - put a copy of the entry below the first one
- X5. CTRL-A - increment the number
- X6. q - stop recording
- X7. <count>@a - repeat the yank, put and increment <count> times
- X
- X
- X<{motion} Shift the {motion} lines one shiftwidth leftwards.
- X
- X<< Shift [count] lines one shiftwidth leftwards.
- X
- X{visual}< Shift the highlighted lines one shiftwidth leftwards
- X (see the chapter on Visual mode). {not in Vi}
- X
- X>{motion} Shift {motion} lines one shiftwidth rightwards.
- X
- X>> Shift [count] lines one shiftwidth rightwards.
- X
- X{visual}> Shift the highlighted lines one shiftwidth
- X rightwards (see the chapter on Visual mode). {not in
- X 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]le[ft] [indent] left align lines in [range]. Sets the indent in the
- X lines to [indent] (default 0). {not in Vi}
- 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 white 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.
- X
- XIf the 'shiftround' option is set, the indent is rounded to a multiple of
- X'shiftwidth'.
- X
- XWhen the 'expandtab' option if off (this is the default) <TAB>s are used as
- Xmuch as possible to make the indent. You can use ">><<" to replace an indent
- Xmade out of spaces with the same indent made out of <TAB>s (and a few
- Xspaces if neccessary). If the 'expandtab' option is on, only spaces are
- Xused. Then you can use ">><<" to replace <TAB>s in the indent by spaces.
- X
- XQ{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 the 'textwidth' option is
- X 0, all lines will be joined together. If the
- X 'autoindent' option is set, the indent of the first
- X line is used for the following lines. The
- X 'formatprg' option can be set to the name of an
- X external program, which will be used instead of the
- X internal function. The 'textwidth' option will then
- X not be used. {not in Vi}
- X
- X:[range]ce[nter] [width]
- X Center lines in [range] between [width] columns
- X (default 'textwidth' or 80 when 'textwidth' is 0).
- X {not in Vi}
- X
- X:[range]ri[ght] [width]
- X right align lines in [range] at [width] columns
- X (default 'textwidth' or 80 when 'textwidth' is 0).
- X {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 [count] lines through the external program
- X {filter}.
- X
- X{visual}!{filter} Filter the highlighted lines through the external
- X program {filter} (see the chapter on Visual mode).
- X {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 [count] lines through the external program
- X given with the 'equalprg' option (default: indent).
- X {not in Vi}
- X
- X{visual}= Filter the highlighted lines through the external
- X program given with the 'equalprg' option (default:
- X indent) (see the chapter on Visual mode). {not in
- X 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, <n> to skip). With
- X [count] that many lines are are searched, starting
- X with the last line number in [range] (default
- X 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 <CR> split line in two at this point
- X CTRL-V <CR> insert a carriage-return (CTRL-M)
- 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:s/abcde/abc^Mde/ modifies "abcde" in "abc", "de" (two lines)
- X:s/$/^V^M/ modifies "abcde" in "abcde^M"
- X
- XNote: To insert a ^M you have to type CTRL-V <CR>. To insert a ^V you have
- Xto type CTRL-V CTRL-V. So to insert the ^V^M in the last example you have to
- Xtype CTRL-V CTRL-V CTRL-V <CR>.
- X
- XBecause CTRL-V <CR> inserts a <CR>, it is impossible to insert a CTRL-V just
- Xin front of a line break. You will have to split it up in two parts:
- X :s/foo/^Vxxxx/
- X :s/xxxx/^M/
- 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
- X put (use uppercase character to append with delete
- X and yank) (<.> 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 [count] lines [into register x] (linewise).
- X
- X["x]Y With 'noyankendofline' option: yank [count] 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{visual}["x]y Yank the highlighed text [into register x] (see the
- X chapter on Visual mode). {not in Vi}
- X
- X{visual}["x]Y Yank the highlighted lines [into register x] (see the
- X chapter on Visual mode). {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
- X[count]
- X times. {Vi: no count}
- X
- X["x]P Put the text [from register x] before the cursor
- X [count] 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 with "." (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 ("p") or above ("P") the line where the cursor
- Xis. Otherwise the text will be inserted after ("p") or before ("P") the
- Xcursor. With the ":put" command the text will always be inserted in the next
- Xline. You can exchange two characters with the command sequence "xp". You
- Xcan exchange two lines with the command sequence "ddp". You can exchange
- Xtwo words with the command sequence "deep" (start with the cursor in the
- Xblank space before the first word). The "']" or "`]" command can be used
- Xafter the put command to move the cursor to the end of the inserted text,
- X"'[" or "`[" to move the cursor to the start.
- X
- XIf the command that was used to get the text into the register used
- Xblockwise Visual mode, the block of text will be inserted before ("P") or
- Xafter ("p") the cursor column, in the current and next lines. Vim will make
- Xthe whole block of text start in the same column. Thus the inserted text
- Xlooks the same as when it was yanked or deleted. Some <TAB> characters may
- Xbe replaced by spaces to make this happen. However, if the width of the
- Xblock is not a multiple of a <TAB> width and the text after the inserted
- Xblock contains <TAB>s, that text may be misaligned.
- X
- XThere are four types of registers: The unnamed regster, 10 numbered
- Xregisters, 26 named registers and two read-only registers.
- X The unnamed register is the register where all text deleted with
- Xthe "d", "c", "s", "x" commands or copied with the yank "y" command is
- Xplaced, regardless of whether or not a specific register was used (e.g.
- X"xdd). The contents of this register are used by any put command (p or P)
- Xwhich does not specify a register. Additionally it can be accessed by the
- Xname <">. This means you have to type two double quotes. {Vi: register
- Xcontents lost when changing files, no <">}
- 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 or the text is less than one line (text deleted with
- X"x" or "dw" will not be put in a numbered register). The contents of
- Xregister <1> are put in <2>, <2> in <3>, and so forth. The contents of
- Xregister <9> are lost. {Vi: numbered register contents are lost when
- Xchanging 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 are lost.
- X The read-only registers are <%> and <.>. They can only be used with the
- Xcommands "p", "P" and ":put". <.> contains the last inserted text (the same
- Xas what is inserted with the insert mode commands CTRL-A and CTRL-@). <%>
- Xcontains the name of the current file.
- X
- XIf you use a put command without specifying a register, the register that
- Xwas last written to is used (this is also the contents of the unnamed
- Xregister). If you are confused, use the ":dis" command to find out what will
- Xbe put (all named and numbered registers are displayed; the unnamed register
- Xis labelled <">).
- 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. Visual mode
- X
- XVisual mode 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
- Xv start/stop Visual mode per character. {not in Vi}
- X
- XV start/stop Visual mode linewise. {not in Vi}
- X
- XCTRL-V start/stop Visual mode blockwise. {not in Vi}
- X
- Xo go to Other end of highlighted text: The current
- X cursor position becomes the start of the highlighted
- X text and the cursor is moved to the Other end of the
- X highlighted text. {not in Vi}
- X
- XTo apply an operator on a piece of text:
- X 1. mark the start of the text with "v", "V" or CTRL-V
- 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 Visual mode up to and
- X including the character under the cursor is highlighted.
- X 3. hit an operator
- X The highlighted characters will be operated upon.
- X
- XThe highlighted text includes the character under the cursor. On terminals
- Xwhere it is possible to make the cursor invisible the cursor position is
- Xalso highlighted. On terminals where this is not possible the cursor is
- Xdisplayed normally.
- X
- XWith "v" the text before the start position 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-V (blockwise Visual mode) the highlighted text will be a rectangle
- Xbetween start position and the cursor. However, some operators work on whole
- Xlines anyway (see the list below). The change and substitute operators will
- Xdelete the highlighted text and then start insertion at the top left
- Xposition.
- X
- XWhen the "$" command is used with blockwise Visual mode, the right end of the
- Xhighlighted text will be determined by the longest highlighted line. This
- Xstops when a motion command is used that does not move straight up or down.
- X
- XIf "v", "V", CTRL-V or ESC is typed while in Visual mode, the highlighting
- Xstops and no text is affected. If you hit CTRL-Z the highlighting stops and
- Xthe editor is suspended 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 cause a beep and Visual mode continues.
- X
- XIf the "v", "V" or CTRL-V is preceded with a count, the previously
- Xhighlighted area is used for a start. You can then move the end of the
- Xhighlighted area and give an operator. The type of the old area is used
- X(character, line or blockwise).
- X- Linewise Visual mode: The number of lines is multiplied with the count.
- X- Blockwise Visual mode: The number of lines and columns is multiplied with
- X the count.
- X- Normal Visual mode within one line: The number of characters is multipled
- X with the count.
- X- Normal Visual mode with several lines: The number of lines is multipled
- X with the count, in the last line the same number of characters is used as
- X in the last line in the previously highlighted area.
- XThe start of the text is the Cursor position. If the "$" command was used as
- Xone of the last commands to extend the highlighted text, the area will be
- Xextended to the rightmost column of the longest line.
- 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 Q format lines to 'textwidth' length (1)
- X
- XAdditionally the following commands can be used:
- X : start ex command for highlighted 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-V
- X(*): in a future a blockwise shift will move the block only, not whole
- X lines.
- X
- XIf you want to give a register name using the """ command, do this just before
- Xtyping the operator character: "v{move around}"xd".
- X
- XWhen repeating a Visual mode operator, the operator will be applied to the
- Xsame amount of text as the last time:
- X- Linewise Visual mode: The same number of lines.
- X- Blockwise Visual mode: The same number of lines and columns.
- X- Normal Visual mode within one line: The same number of characters.
- X- Normal Visual mode with several lines: The same number of lines, in the
- X last 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 highlighted text, the repeating will
- Xbe applied up to 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. Type an index
- X character to go directly to a page. Type <SPACE> or
- X CTRL-F (with MSDOS: page-down) to go one page
- X forward. Type <b> or CTRL-B (with MSDOS: page-up) to
- X go one page back. Type <a> to go back to the index.
- X Type <CR> to get out of the help screen. {Vi: no
- X 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:[range]l[ist] [count]
- X Same as :print, but display unprintable characters
- X with <^>.
- X
- X:[range]nu[mber] [count]
- X Same as :print, but precede each line with its line
- X number.
- X
- X:= Print the line number.
- X
- X:sh[ell] Escape to a shell (name from 'shell' option).
- X
- X:![!]{cmd} [!][arg] Execute {cmd} with the shell. The optional bangs are
- X replaced with the previously given command. The
- X optional [arg] is appended. See also the 'shell' and
- X 'shelltype' option.
- X
- X:ve[rsion] Print the version number of the editor.
- X
- XK Run a program to lookup the identifier under the
- X cursor. The name of the program is given with the
- X 'keywordprg' (kp) option. The identifier is formed
- X of letters, numbers and the underscore. The
- X identifier under or right of the cursor is used. The
- X same can be done with the command
- X ":!{program} {identifier}".
- X {not in Vi}
- X
- X
- X 15. Repeating commands
- X
- X15.1 Single repeats
- X
- X. Repeat last change with count replaced by [count].
- X
- XSimple changes can be repeated with the "." command. Without a count, the
- Xcount of the last change is used. If you enter a count, it will replace the
- Xlast one. If the last change included a specification of a numbered
- Xregister, the register number will be incremented. See the section on undo
- Xand redo for an example how to use this.
- X
- X
- X15.2 Multiple repeats
- X
- X:[range]g[lobal]/{pattern}/[cmd]
- X Execute the Ex command [cmd] (default ":p") on the
- X lines within [range] where {pattern} matches.
- X
- X:[range]g[lobal]!/{pattern}/[cmd]
- X Execute the Ex command [cmd] (default ":p") on the
- X lines within [range] where {pattern} does NOT match.
- X
- X:[range]v[global]/{pattern}/[cmd]
- X Same as :g!.
- X
- XThe global commands work by first scanning through the [range] lines and
- Xmarking each line where a match occurs. In a second scan the [cmd] is
- Xexecuted for each marked line with its line number prepended. If a line is
- Xchanged or deleted its mark disappears. The default for [range] is the whole
- Xbuffer (1,$). Use "CTRL-C" to interrupt the command.
- X
- XTo repeat a non-Ex command, you will have to put the command in a file and
- Xuse "source!". For example:
- X :g/pat/so! scriptfile
- XMake sure that the scriptfile ends with a whole command, otherwise Vim will
- Xwait for you to type the rest of the command for each match. The screen will
- Xnot have been updated, so you don't know what you are doing.
- X
- XThe undo/redo command will undo/redo the whole global command at once.
- X
- X
- X15.3 Complex repeats
- X
- Xq<0-9a-zA-Z"> Record typed characters into register <0-9a-zA-Z">
- X (uppercase to append). The 'q' that stops recording
- X is also stored in the register. The 'q' command is
- X disabled while executing a register. (Implementation
- X note: This was done because the 'q' command can be
- X the result of mapping). {Vi: no recording}
- X
- Xq Stops recording. {Vi: no recording}
- X
- X@<0-9a-z"> Execute the contents of register <0-9a-z"> [count]
- X times. {Vi: only named registers}
- X
- X@@ Repeat the previous @<0-9a-z"> [count] times.
- X
- X:@<0-9a-z"> Execute the contents of register <0-9a-z"> as
- X an Ex command. {Vi: only in some versions}
- X
- X:@@ Repeat the previous :@<0-9a-z">. {Vi: only in some
- X versions}
- X
- X:so[urce] {file} Read Ex commands from {file}.
- X
- X:so[urce]! {file} Read Vim commands from {file}. {not in Vi}
- X
- XAll commands and command sequences can be repeated by putting them in a named
- Xregister and then executing it. There are two ways to get the commands in the
- Xregister:
- X- Use the record command "q". You type the commands once, and while they are
- X being executed they are stored in a register. Easy, because you can see
- X what you are doing. If you make a mistake, 'put' the register into the
- X file, edit the command sequence, and then delete it into the register
- X again. You can continue recording by appending to the register (use an
- X uppercase letter).
- X- Delete or yank the command sequence into the register.
- X
- XOften used command sequences can be put under a function key with the ':map'
- Xcommand.
- X
- XAn alternative is to put the commands in a file, and execute them with the
- X':source!' command. Useful for long command sequences. Can be combined with
- Xthe ':map' command to put complicated commands under a function key.
- X
- XThe ':source' command reads Ex commands from a file line by line. You will
- Xhave to type any needed keyboard input. The ':source!' command reads from a
- Xscript file character by character, interpreting each character as if you
- Xtyped it.
- X
- XExample: When you give the ":!ls" command you are asked to "hit return to
- Xcontinue". If you ':source' a file with the line "!ls" in it, you will have
- Xto type the return yourself. But if you ':source!' a file with the line
- X":!ls" in it, the next characters from that file are read until a <CR> is
- Xfound. You will not have to type <CR> yourself, unless ":!ls" was the last
- Xline in the file.
- X
- XIt is possible to put ':source[!]' commands in the script file, so you can
- Xmake a top-down hierachy of script files. The ':source' command can be
- Xnested as deep as the number of files that can be opened at one time (about
- X15). The ':source!' command can be nested up to 15 levels deep.
- X
- XIn script files terminal-dependent key codes are represented by
- Xterminal-independent single character codes. In the MSDOS version the values
- Xare 48 (0x30) higher. Any of these codes can be entered with CTRL-V followed
- Xby the three digit decimal code.
- X
- X code hex meaning
- X
- X 128 0x80 up-arrow
- X 129 0x81 down-arrow
- X 130 0x82 left-arrow
- X 131 0x83 right-arrow
- X 132 0x84 shift up-arrow
- X 133 0x85 shift down-arrow
- X 134 0x86 shift left-arrow
- X 135 0x87 shift right-arrow
- X
- X 136 0x88 function key 1
- X 137 0x89 function key 2
- X 138 0x8a function key 3
- X 139 0x8b function key 4
- X 140 0x8c function key 5
- X 141 0x8d function key 6
- X 142 0x8e function key 7
- X 143 0x8f function key 8
- X 144 0x90 function key 9
- X 145 0x91 function key 10
- X
- X 146 0x92 shifted function key 1
- X 147 0x93 shifted function key 2
- X 148 0x94 shifted function key 3
- X 149 0x95 shifted function key 4
- X 150 0x96 shifted function key 5
- X 151 0x97 shifted function key 6
- X 152 0x98 shifted function key 7
- X 153 0x99 shifted function key 8
- X 154 0x9a shifted function key 9
- X 155 0x9b shifted function key 10
- X
- X 156 0x9c help key
- X 157 0x9d undo key
- X 158 0x9e special-function key follows (MSDOS)
- X 159 0x9f CTRL-@
- X
- X
- X 16. Undo and redo
- X
- X<UNDO> or
- Xu Undo [count] changes. {Vi: only one level}
- X
- X:u[ndo] Undo one change. {Vi: only one level}
- X
- XCTRL-R Redo [count] changes which were undone. {Vi: redraw
- X screen}
- X
- X:red[o] Redo one change which was unodone. {Vi: no redo}
- X
- XU Undo all latest changes on one line. {Vi: while not
- X moved off of it}
- X
- XThe last changes are remembered. You can go back in time with the "u"
- Xcommand. You can then go forward again with the 'CTRL-R' command. If you
- Xmake a new change after the "u" command, the 'CTRL-R' will not be possible
- Xanymore. The number of changes that are remembered is set with the
- X'undolevels' option. If it is zero, the old fashioned Vi undo is present:
- Xone level of undo and undo undoes itself. If it is negative no undo is
- Xpossible. Use this if you are running out of memory.
- X
- XThe "U" command is treated by undo/redo just like any other command. Thus a
- X"u" command undos a "U" command and a 'CTRL-R' command redoes it again. When
- Xmixing "U", "u" and 'CTRL-R' you will notice that the "U" command will
- Xrestore the situation of a line to before the previous "U" command. This may
- Xbe confusing. Try it out to get used to it.
- X
- XThe numbered registers can also be used for undoing deletes. Each time you
- Xdelete text, it is put into register "1. The contents of register "1 are
- Xshifted to "2, etc. The contents of register "9 are lost. You can now get
- Xback the most recent deleted text with the put command: '"1P'. (also, if the
- Xdeleted text was the result of the last delete or copy operation, 'P' or 'p'
- Xalso works as this puts the contents of the unnamed register). You can get
- Xback the text of three deletes ago with '"3P'.
- X
- XIf you want to get back more than one part of deleted text, you can use a
- Xspecial feature of the repeat command ".". It will increase the number of the
- Xregister used. So if you first do ""1P", the following "." will result in a
- X'"2P'. Repeating this will result in all numbered registers being inserted.
- X
- XExample: If you deleted text with 'dd....' it can be restored with
- X '"1P....'.
- X
- XIf you don't know in which register the deleted text is, you can use the
- X:display command. An alternative is to try the first register with '"1P', and
- Xif it is not what you want do 'u.'. This will remove the contents of the
- Xfirst put, and repeat the put command for the second register. Repeat the
- X'u.' until you got what you want.
- X
- X
- X 17. Key mapping
- X
- X:map {lhs} {rhs} Map the key sequence {lhs} to {rhs} in Command mode.
- X
- X:map! {lhs} {rhs} Map the key sequence {lhs} to {rhs} in Insert and
- X Command_line mode.
- X
- X:noremap {lhs} {rhs} Map the key sequence {lhs} to {rhs} in Command mode.
- X Disallow remapping of {rhs}. {not in Vi}
- X
- X:noremap! {lhs} {rhs} Map the key sequence {lhs} to {rhs} in insert and
- X Command_line mode. Disallow remapping of {rhs}. {not
- X in Vi}
- X
- X:unm[ap] {lhs} Remove the mapping of {lhs} for Command mode.
- X
- X:unm[ap]! {lhs} Remove the mapping of {lhs} for Insert and
- X Command_line mode.
- X
- X:map List all key mappings for Command mode.
- X
- X:map! List all key mappings for Insert and Command_line
- X mode.
- X
- X:map {lhs} List the key mappings for the key sequences starting
- X with {lhs} in Command mode. {not in Vi}
- X
- X:map! {lhs} List the key mappings for the key sequences starting
- X with {lhs} in insert and Command_line mode. {not in Vi}
- X
- X:cm[ap] Same as :map, but for Command_line mode only. {not
- X in Vi}
- X
- X:cu[nmap] Same as :unmap, but for Command_line mode only.
- X {not in Vi}
- X
- X:cno[remap] Same as :noremap, but for Command_line mode only.
- X {not in Vi}
- X
- X:im[ap] Same as :map, but for Insert mode only. {not in Vi}
- X
- X:iu[nmap] Same as :unmap, but for Insert mode only. {not in
- X Vi}
- X
- X:ino[remap] Same as :noremap, but for Insert mode only. {not in
- X Vi}
- X
- XThese commands are used to map a key or key sequence to a string of
- Xcharacters. You can use this to put command sequences under function keys,
- Xtranslate one key into another, etc. See the "Options" chapter below for how
- Xto save and restore the current mapping.
- X
- XThere are three sets of mappings
- X- For Insert mode. These are also used in Replace mode.
- X- For Command_line mode: When entering a ":" or "/" command.
- X- For Command mode: When typing commands.
- X
- XThe original vi did not have separate mappings for Insert mode and
- XCommand_line mode. Therefore the ":map!" command enters and displays
- Xmappings for both. In Vim you can use the ":cmap" and ":imap" commands to
- Xenter mappings for each mode separately. When listing mappings with ":map!",
- X":cmap" or ":imap" the character in column 1 is <!> for mappings in both
- XInsert and Command_line mode, <i> for Insert mode only and <c> for
- XCommand_line mode only.
- X
- XEverything from the first non-blank after {lhs} up to the end of the line
- X(or <|>) is considered to be part of {rhs}. This allows the {rhs} to end
- Xwith a space.
- X
- XTo include a space in {lhs} precede it with a CTRL-V (type two CTRL-Vs for
- Xeach space). If you want a {rhs} that starts with a space, precede {rhs}
- Xwith a single CTRL-V (You have to type CTRL-V two times). You can create an
- Xempty {rhs} by typing nothing after the two CTRL-Vs.
- X
- XIt is not possible to put a comment after this command, because the <">
- Xcharacter is considered to be part of the {rhs}. To put a <|> in {rhs}
- Xescape it with a backslash or a CTRL-V (to get one CTRL-V you have to type
- Xit twice).
- X
- XTo avoid mapping of the characters you type in insert or Command_line mode,
- Xtype a CTRL-V first. The mapping in Insert mode is disabled if the 'paste'
- Xoption is set.
- X
- XNote that the second character (argument) of the commands @zZtTfF[]rm'`"v is
- Xnot mapped. This was done to be able to use all the named registers and
- Xmarks, even when the command with the same name has been mapped.
- X
- XSome examples (given as you type them; e.g. the "^V" is CTRL-V which you
- Xtype, but will not show up on the screen):
- X
- X :map g /foo^V^Mcwbar^V^[ (replace next "foo" by "bar")
- X :map! qq quadrillion questions
- X
- XVim will compare what you type with the start of a mapped sequence. If there
- END_OF_FILE
- if test 44166 -ne `wc -c <'vim/doc/reference.do3'`; then
- echo shar: \"'vim/doc/reference.do3'\" unpacked with wrong size!
- fi
- chmod +x 'vim/doc/reference.do3'
- # end of 'vim/doc/reference.do3'
- fi
- echo shar: End of archive 21 \(of 25\).
- cp /dev/null ark21isdone
- 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 24 25 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 25 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
-
- ===============================================================================
- 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 595473 | whatever will be accepted.
-
- exit 0 # Just in case...
-