home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso
/
misc
/
volume41
/
vim
/
part22
< prev
next >
Wrap
Text File
|
1993-12-21
|
49KB
|
1,166 lines
Newsgroups: comp.sources.misc
From: mool@oce.nl (Bram Moolenaar)
Subject: v41i072: vim - Vi IMitation editor, v2.0, Part22/25
Message-ID: <1993Dec21.172842.2226@sparky.sterling.com>
X-Md4-Signature: a82ff193c3127998b91612d1334970a0
Keywords: utility, editor, vi, vim
Sender: kent@sparky.sterling.com (Kent Landfield)
Organization: Sterling Software
Date: Tue, 21 Dec 1993 17:28:42 GMT
Approved: kent@sparky.sterling.com
Submitted-by: mool@oce.nl (Bram Moolenaar)
Posting-number: Volume 41, Issue 72
Archive-name: vim/part22
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 22 (of 25)."
# Contents: vim/doc/reference.do2
# 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.do2' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/doc/reference.do2'\"
else
echo shar: Extracting \"'vim/doc/reference.do2'\" \(45369 characters\)
sed "s/^X//" >'vim/doc/reference.do2' <<'END_OF_FILE'
X available. Vim tries to detect the type of filesystem when it is
X creating the .vim file. If an MSDOS-like filesystem is suspected,
X a flag is set that has the same effect as setting the 'shortname'
X option. This flag will be reset as soon as you start editing a
X new file. The flag will be used when making the filename for the
X ".vim" and ".bak" files for the current file. But when you are
X editing a file in a normal filesystem and write to an MSDOS-like
X filesystem the flag will not have been set. In that case the
X creation of the ".bak" file may fail and you will get an error
X message. Use the 'shortname' option in this case.
X
XVim remembers whether you have changed the buffer. You are protected from
Xlosing the changes you made. If you try to quit without writing, or want to
Xstart editing another file, this will be refused. In order to overrule this
Xprotection add a <!> to the command. The changes will then be lost. For
Xexample: ":q" will not work if the buffer was changed, but ":q!" will. To see
Xwhether the buffer was changed use the "CTRL-G" command. The message includes
Xthe string "[Modified]" if the buffer has been changed.
X
X
X5.2 Editing a file
X
X:e[dit] [+pat] Edit the current file, unless changes have been made.
X
X:e[dit]! [+pat] Edit the current file always. Discard any changes to
X the buffer.
X
X:e[dit] [+pat] {file} Edit {file}, unless changes have been made.
X
X:e[dit]! [+pat] {file} Edit {file} always. Discard any changes to the
X buffer.
X
X:e[dit] #[count] Edit the [count]th alternate filename (as shown by
X :files). Omitting [count] is equivalent to CTRL-^.
X
X:ex [+pat] [file] Same as :edit. {Vi: go from visual to Ex mode}
X
X:vi[sual] [+pat] [file] Same as :edit. {Vi: go from Ex to Visual mode}
X
X[count]CTRL-^ Edit [count]th alternate file (equivalent to ":e
X #[count]"). Without count this gets you to the
X previously edited file. This is a quick way to
X toggle between two (or more) files. If the
X 'autowrite' option is set and the buffer was
X changed, write it.
X
X:cd On non-Unix systems: Print the current directory
X name. On Unix systems: Change the current directory
X to the home directory.
X
X:cd {path} Change the current directory to {path}. Does not
X change the meaning of an already entered file name,
X because its full path name is remembered.
X
X:chd[ir] [path] Same as :cd.
X
X:pwd Print the current directory name. {Vi: no pwd}
X
XThese commands are used to start editing a single file. This means that the
Xfile is read into the buffer and the current filename is set. You may use the
X":cd" command to get to another directory, so you will not have to type that
Xdirectory name in front of the filenames. One warning: After using ":cd" the
Xfull path name will be used for reading and writing files. On some networked
Xfile systems this may cause problems. The result of using the full path name
Xis that the file names currently in use will remain refering to the same
Xfile. Example: If you have a file a:test and a directory a:vim the commands
X":e test" ":cd vim" ":w" will overwrite the file a:test and not write
Xa:vim/test. But if you do ":w test" the file a:vim/test will be written,
Xbecause you gave a new file name and did not refer to a file name before the
X":cd".
X
XYou can use the ":e!" command if you messed up the buffer and want to start
Xall over again. The ":e" command is only useful if you have changed the
Xcurrent filename.
X
XThe [+pat] can be used to position the cursor in the newly opened file:
X + Start at the last line.
X +{num} Start at line {num}.
X +/{pat} Start at first line containing {pat}. {pat} must not
X contain any spaces.
X +{command} Execute {command} after opening the new file.
X {command} is an Ex command. It must not contain
X spaces.
X
XWhen reading a file when the 'textmode' option is off (default for
Xnon-MSDOS) the <LF> character is interpreted as end-of-line. If 'textmode'
Xis on (default for MSDOS), <CR><LF> is also interpreted as end-of-line.
X
XWhen writeing a file when the 'textmode' option is off a <LF> character is
Xused to separate lines. When the 'textmode' option is on <CR><LF> is used.
X
XYou can read a file with 'textmode' set and write it with 'textmode' reset.
XThis will replace all <CR><LF> pairs by <LF>. If you read a file with
X'textmode' reset and write with 'textmode' set, all <LF> characters will be
Xreplaced by <CR><LF>.
X
XIf you start editing a new file and the 'textauto' option is set, Vim will
Xtry to detect whether the lines in the file are separated by a single <LF>
X(as used on Unix and Amiga) or by a <CR><LF> pair (MSDOS). It reads up to
Xthe first <LF> and checks if there is a <CR> in front of it. If there is the
X'textmode' option is set, otherwise it is reset. If the 'textmode' option is
Xset on non-MSDOS systems the message "[textmode]" is shown to remind you
Xthat something unusual is happening. On MSDOS systems you get the message
X"[notextmode]" if the 'textmode' option is not set.
X
XBefore editing binary, executable or Vim script files you should set the
X'textmode' and 'textauto' options off. With 'textmode' on you risc that
Xsingle <LF> characters are unexpectedly replaced with <CR><LF>. A simple way
Xto do this is by starting Vim with the "-b" option.
X
X
X5.3 The file list
X
XIf you give more than one filename when starting Vim, this list is remembered
Xas the file list. You can use this list with the following commands:
X
X:ar[gs] Print the file list, with the current file in "[]".
X
X:[count]n[ext] Edit [count] next file, unless changes have been
X made and the 'autowrite' option is off {Vi: no
X count}.
X
X:[count]n[ext]! Edit [count] next file, discard any changes to the
X buffer {Vi: no count}.
X
X:n[ext] [+pat] {filelist}
X Define {filelist} as the new list of files and edit
X the first one, unless changes have been made and the
X 'autowrite' option is off.
X
X:n[ext]! [+pat] {filelist}
X Define {filelist} as the new list of files and edit
X the first one. Discard any changes to the buffer.
X
X:[count]N[ext] Edit [count] previous file in file list, unless
X changes have been made and the 'autowrite' option is
X off {Vi: no count}.
X
X:[count]N[ext]! Edit [count] previous file in file list. Discard any
X changes to the buffer {Vi: no count}.
X
X:[count]pre[vious] Same as :Next {Vi: only in some versions}
X
X:rew[ind] Start editing the first file in the file list, unless
X changes have been made and the 'autowrite' option is
X off.
X
X:rew[ind]! Start editing the first file in the file list.
X Discard any changes to the buffer.
X
X:[count]wn[ext] Write current file and start editing the [count]
X next file. {not in Vi}
X
X:[count]wn[ext] {file} Write current file to {file} and start editing the
X [count] next file, unless {file} already exists and
X the 'writeany' option is off.
X {not in Vi}
X
X:[count]wn[ext]! {file} Write current file to {file} and start editing the
X [count] next file. {not in Vi}
X
XThe [count] in the commands above defaults to one.
X
XThe wildcards in the file list are expanded and the filenames are sorted.
XThus you can use the command "vim *.c" to edit all the C files. From within
XVim the command ":n *.c" does the same.
X
XYou are protected from leaving Vim if you are not editing the last file in
Xthe file list. This prevents you from forgetting that you were editing one
Xout of several files. You can exit anyway, and save any changes, with the
X":wq!" command. To lose any changes use the ":q!" command.
X
X
X5.4 Writing and quitting
X
X:[range]w[rite][!] Write the specified lines to the current file.
X
X:[range]w[rite] {file} Write the specified lines to {file}, unless it
X already exists and the 'writeany' option is off.
X
X:[range]w[rite]! {file} Write the specified lines to {file}. Overwrite an
X existing file.
X
X:[range]w[rite][!] >> Append the specified lines to the current file.
X
X:[range]w[rite][!] >> {file}
X Append the specified lines to {file}. <!> forces the
X write even if file does not exist.
X
X:[range]w[rite] !{cmd} Execute {cmd} with [range] lines as standard input
X (note the space in front of the <!>).
X
XThe default [range] for the ":w" command is the whole buffer (1,$).
X
X
X:q[uit] Quit, unless changes have been made or not editing
X the last file in the file list.
X
X:q[uit]! Quit always, without writing.
X
X:cq Quit always, without writing, and return an error
X code. Used for Manx's QuickFix mode (see 5.5).
X
X:wq Write the current file. Exit if not editing the
X last file in the file list.
X
X:wq! Write the current file and exit.
X
X:wq {file} Write to {file}. Exit if not editing the last
X file in the file list.
X
X:wq! {file} Write to {file} and exit.
X
X:x[it][!] [file] Like ":wq", but write only when changes have been
X made.
X
XZZ Write current file, if modified, and exit (same as
X ":x").
X
XIf you write to an existing file (but do not append) while the 'backup' or
X'writebackup' option is on, a backup of the original file is made. On Unix
Xsystems the file is copied, on other systems the file is renamed. After the
Xfile has been successfully written and when the 'writebackup' option is on
Xand the 'backup' option is off, the backup file is deleted.
X
X'backup' 'writebackup' action
X off off no backup made
X off on backup made, deleted afterwards
X on off backup made, not deleted
X on on backup made, not deleted (default)
X
XOn Unix systems:
XWhen you write to an existing file, that file is truncated and then filled
Xwith the new text. This means that protection bits, owner and symbolic links
Xare unmodified. The backup file however, is a new file, owned by the user
Xwho edited the file. If it is not possible to create the backup file in the
Xsame directory as the original file, the directory given with the
X'backupdir' option is used (default: home directory).
X
XIf the creation of a backup file fails, the write is not done. If you want
Xto write anyway add a <!> to the command.
X
XIf the 'textmode' option is set <CR><LF> is used for end-of-line. This is
Xdefault for MSDOS. On other systems the message "[textmode]" is shown to
Xremind you that an usual end-of-line marker was used. If the 'textmode' is
Xnot set LF is used for end-of-line. On MSDOS the message "[notextmode]" is
Xshown. See also the 'textmode' and 'textauto' options.
X
X
X5.5 Using the QuickFix mode
X
XVim has a special mode to speedup the edit-compile-edit cycle. This is
Xinspired by the quickfix option of the Manx's Aztec C compiler on the Amiga.
XThe idea is to save the error messages from the compiler in a file and use
XVim to jump to the errors one by one. You can then examine each problem and
Xfix it, without having to remember all the error messages.
X
XIf you are using Manx's Aztec C compiler on the Amiga you should do the
Xfollowing:
X- Set the CCEDIT environment variable with the command
X mset "CCEDIT=vim -e"
X- Compile with the -qf option. If the compiler finds any errors, Vim is
X started and the cursor is positioned on the first error. The error message
X will be displayed on the last line. You can go to other errors with the
X commands mentioned below. You can fix the errors and write the file(s).
X- If you exit Vim normally the compiler will re-compile the same file. If you
X exit with the :cq command, the compiler will terminate. Do this if you
X cannot fix the error, or if another file needs to be compiled first.
X
XIf you are using another compiler you should save the error messages in a
Xfile and start Vim with "vim -e filename". An easy way to do this is with
Xthe ":make" command (see below). The 'errorformat' option should be set to
Xmatch the error messages from your compiler (see below).
X
XThe following commands can be used if you are in QuickFix mode:
X
X:cc [nr] Display error [nr]. If [nr] is omitted, the same
X error is displayed again. {not in Vi}
X
X:cn Display the next error in the list that includes a
X file name. If there are no file names at all, go the
X the next error. {not in Vi}
X
X:cp Display the previous error in the list that includes
X a file name. If there are no file names at all, go
X the the previous error. {not in Vi}
X
X:cq Quit Vim with an error code, so that the compiler
X will not compile the same file again. {not in Vi}
X
X:cf [errorfile] Read the error file and jump to the first error.
X This is done automatically when Vim is started with
X the -e option. You can use this command when you
X keep Vim running while compiling. If you give the
X name of the errorfile, the 'errorfile' option will
X be set to [errorfile] {not in Vi}
X
X:cl List all errors. {not in Vi}
X
X:make [arguments] 1. If the 'autowrite' option is set and the buffer
X was changed, write it.
X 2. Any existing 'errorfile' is deleted.
X 3. The program given with the 'makeprg' option is
X started (default "make") with the optional
X [arguments] and the output is saved in
X 'errorfile' (for Unix it is also echoed on the
X screen).
X 4. The 'errorfile' is then read and the first error
X is jumped to.
X 5. The 'errorfile' is deleted.
X {not in Vi}
X
XThe name of the file can be set with the 'errorfile' option. The default is
X"AztecC.Err" for the Amiga and "errors" for other systems. The format of the
Xfile from the Aztec compiler is:
X
X filename>linenumber:columnnumber:errortype:errornumber:errormessage
X
X filename name of the file in which the error was detected
X linenumber line number where the error was detected
X columnnumber column number where the error was detected
X errortype type of the error, normally a single <E> or <W>
X errornumber number of the error (for lookup in the manual)
X errormessage description of the error
X
XAnother compiler is likely to use a different format. You should set the
X'errorformat' option to a scanf-like string that describes the format. First
Xyou need to know how scanf works. Look in the documentation of your C
Xcompiler. Vim will understand eight conversion characters. Others are invalid.
X %f file name (finds a string)
X %l line number (finds a number)
X %c column number (finds a number)
X %t error type (finds a single character)
X %n error number (finds a number)
X %m error message (finds a string)
X %*<conv> any scanf non-assignable conversion
X %% the single <%> character
X
XExamples:
X"%f>%l:%c:%t:%n:%m" for the AztecC.Err file
X"%f:%l:\ %t%*[^0123456789]%n:\ %m" for Aztec C error messages
X"%f\ %l\ %t%*[^0123456789]%n:\ %m" for SAS C
X"\"%f\",%*[^0123456789]%l:\ %m" default for generic C compilers
X
XNote the backslash in front of a space and double quote. It is required for
Xthe :set command.
X
XThe "%f" and "%m" conversions have to detect the end of the string. They
Xshould be followed by a character that cannot be in the string. Everything
Xup to that character is included in the string. Be careful: "%f%l" will
Xinclude everything up to the first <%> in the file name. If the "%f" or "%m"
Xis at the end, everything up to the end of the line is included.
X
XIf a line is detected that does not completely match the 'errorformat', the
Xwhole line is put in the error message and the entry is marked "not valid"
XThese lines are skipped with the ":cn" and ":cp" commands (unless there is
Xno valid line at all). You can use ":cl" to display all the error messages.
X
XIf the error format does not contain a file name Vim cannot switch to the
Xcorrect file. You will have to do this by hand.
X
XIf you have a compiler that produces error messages that do not fit in the
Xformat string, you could write a program that translates the error messages
Xinto this format. You can use this program with the ":make" command by
Xchanging the 'makeprg' option. For example:
X ":set mp=make\ \\\|&\ error_filter".
XThe backslashes before the pipe character are required to avoid it to be
Xrecognized as a command separator. The backslash before each space is
Xrequired for the set command.
X
XThe ":make" command executes the command given with the 'makeprg' option.
XThis is done by passing the command to the shell given with the 'shell'
Xoption. This works almost like typing
X
X ":!{makeprg} >{errorfile} [arguments]".
X
X{makeprg} is the string given with the 'makeprg' option. Any command can be
Xused, not just "make". Characters <%> and <#> are expanded as usual on a
Xcommand line. You can use "#<" to insert the current filename without
Xextension, for example ":set makeprg=make\ #<.o".
X
X{errorfile} is the 'errorfile' option.
X
X[arguments] is anything that is typed after ":make".
X
XThere are some restrictions to the Quickfix mode on the Amiga. The
Xcompiler only writes the first 25 errors to the errorfile (Manx's
Xdocumentation does not say how to get more). If you want to find the others,
Xyou will have to fix a few errors and exit the editor. After recompiling,
Xup to 25 remaining errors will be found.
X
XOn the Amiga, if Vim was started from the compiler, the :sh and :! commands
Xwill not work, because Vim is then running in the same process as the
Xcompiler and these two commands may guru the machine then.
X
XIf you insert or delete lines, mostly the correct error location is still
Xfound because hidden marks are used (Manx's Z editor does not do this).
XSometimes, when the mark has been deleted for some reason, the message "line
Xchanged" is shown to warn you that the error location may not be correct. If
Xyou edit another file the marks are lost and the error locations may not be
Xcorrect anymore.
X
X
X5.6 Editing binary files
X
XAlthough Vim was made to edit text files, it is possible to edit binary
Xfiles. The "-b" command line option (b for binary) sets some options for
Xediting binary files ('binary' on, 'textwidth' to 0, 'textmode' and
X'textauto' off, 'modelines' to 0, 'expandtab' off). Setting the 'binary'
Xoption has the same effect. Don't forget to do this before reading the file.
X
XThere are a few things to remember when editing binary files:
X- When editing executable files the number of characters must not change.
X Use only the "R" or "r" command to change text. Do not delete characters
X with "x" or by backspacing.
X- Set the 'textwidth' option to 0. Otherwise lines will unexpectedly be
X split in two.
X- When there are not many end-of-line characters, the lines will become very
X long. If you want to edit a line that does not fit on the screen reset the
X 'wrap' option. Horizontal scrolling is used then. If a line becomes too
X long (more than about 32767 characters on the Amiga, much more on 32-bit
X systems) you cannot edit that line. It is also possible that you get an
X "out of memory" error when reading the file.
X- Make sure the 'textmode' and 'textauto' options are off before loading the
X file. In 'textmode' both <CR><LF> and <LF> are considered to end a line
X and when the file is written the <LF> will be replaced by <CR><LF>. The
X 'modelines' option should also be off, because there may be a string like
X ":vi:" in the file that would give unpredictable results.
X- <NUL> characters are shown on the screen as ^@. You can enter them with
X "CTRL-V CTRL-@" or "CTRL-V 000" {vi cannot handle <NUL> characters in the
X file}
X- To insert a <LF> character in the file split up a line. When writing the
X buffer to a file a <LF> will be written for the end of line.
X- Vim normally appends an end-of-line character at the end of the file if
X there is none. Setting the 'binary' option prevents this. If you want to
X add the final end-of-line, append an empty line at the end.
X
X
X 6. Cursor motions
X
XThese commands move the cursor position. If the new position is off of the
Xscreen, the screen is scrolled to show the cursor (see also 'scrolljump'
Xoption).
X
XThe motion commands can be used after other commands, called operators, to
Xhave the command operate on the text that was moved over. That is the text
Xbetween the cursor position before and after the motion. If the motion
Xincludes a count and the operator also had a count, the two counts are
Xmultiplied. For example: "2d3w" deletes six words.
X The operator either affects whole lines, or the characters between
Xthe start and end position. Generally, motions that move between lines
Xaffect lines (are linewise), and motions that move within a line affect
Xcharacters. However, there are some exceptions.
X A character motion is either inclusive or exclusive. When inclusive,
Xthe start and end position of the motion are included in the operation.
XWhen exclusive, the last character towards the end of the buffer is not
Xincluded. Linewise motions always include the start and end position.
X Which motions are linewise, inclusive or exclusive is mentioned
Xbelow. There are however, two general exceptions:
X1. If the motion is exclusive and the end of the motion is in column 1, the
X end of the motion is moved to the end of the previous line and the motion
X becomes inclusive. Example: "}" ends at the first line after a paragraph,
X but "V}" will not include that line.
X2. If the motion is exclusive, the end of the motion is in column 1 and the
X start of the motion was at or before the first non-blank in the line, the
X motion becomes linewise. Example: If a paragraph begins with some blanks
X and you do "d}" while standing on the first non-blank, all the lines of
X the paragraph are deleted, including the blanks. If you do a put now, the
X deleted lines will be inserted below the cursor position.
X
XInstead of first giving the operator and then a motion you can use Visual
Xmode: mark the start of the text with <v>, move the cursor to the end of the
Xtext that is to be affected and then hit the operator. The text between the
Xstart and the cursor position is highlighted, so you can see what text will
Xbe operated upon. This allows much more freedom, but requires more key
Xstrokes and has limited redo functionality. See the chapter on Visual mode.
X
XIf you want to know where you are in the file use the "CTRL-G" command. If
Xyou set the 'ruler' option, the cursor position is continuously shown in the
Xstatus line (which slows down Vim a little).
X
XNOTE: Experienced users prefer the hjkl keys because they are always right
Xunder their fingers. Beginners often prefer the arrow keys, because they
Xdo not know what the hjkl keys do. The mnemonic value of hjkl is clear from
Xlooking at the keyboard. Think of j as an arrow pointing downwards.
X
X6.1 Left-right motions
X
Xh or
X<C_LEFT> or
XCTRL-H or
X<BS> [count] characters to the left (exclusive).
X
Xl or
X<C_RIGHT> or
X<SPACE> [count] characters to the right (exclusive).
X
X0 To the first character of the line (exclusive).
X
X^ To the first non-blank character of the line
X (exclusive).
X
X$ To the end of line [count] from the cursor
X (inclusive).
X
X| To column [count] (inclusive).
X
Xf<char> To [count]'th occurrence of <char> to the right. The
X cursor is placed on <char> (inclusive).
X
XF<char> To the [count]'th occurrence of <char> to the left.
X The cursor is placed on <char> (inclusive).
X
Xt<char> Till before [count]'th occurrence of <char> to the
X right. The cursor is placed on the character left of
X <char> (inclusive).
X
XT<char> Till after [count]'th occurrence of <char> to the
X left. The cursor is placed on the character right of
X <char> (inclusive).
X
X; Repeat latest f, t, F or T [count] times.
X
X, Repeat latest f, t, F or T in opposite direction
X [count] 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 [count] lines upward (linewise).
X
Xj or
X<C_DOWN> or
XCTRL-J or
X<LF> or
XCTRL-N [count] lines downward (linewise).
X
X- <minus> [count] lines upward, on the first non-blank
X character (linewise).
X
X+ or
XCTRL-M or
X<CR> [count] lines downward, on the first non-blank
X character (linewise).
X
X_ <underscore> [count] - 1 lines downward, on the first non-blank
X character (linewise).
X
XG Goto line [count], 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{count}% Go to {count} percentage in the file, column 1
X (linewise). To compute the new line number this
X formula is used: {count} * number-of-lines / 100.
X {not 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 [count] words forward (exclusive).
X
XW [count] WORDS forward (exclusive).
X
Xe Forward to the end of word [count] (inclusive).
X
XE Forward to the end of WORD [count] (inclusive).
X
X<SC_LEFT> or
Xb [count] words backward (exclusive).
X
XB [count] 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 white space (spaces, tabs, end of line). A WORD
Xconsists of a sequence of non-blank characters, separated with white space.
XAn empty line is also considered to be a word and 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 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
XAnother special case: When using the "w" motion in combination with an
Xoperator and the last word moved over is at the end of a line, the end of
Xthat word becomes the end of the operated text, not the first word in the
Xnext line.
X
XThe original vi implementation of "e" is buggy. For example, the "e" command
Xwill stop on the first character of a line if the previous line was empty.
XBut when you use "2e" this does not happen. In Vim "ee" and "2e" are the
Xsame, which is more logical. However, this causes a small incompatibility
Xbetween vi and Vim.
X
X
X6.4 Text object motions
X
X( [count] sentences backward (exclusive).
X
X) [count] sentences forward (exclusive).
X
X{ [count] paragraphs backward (exclusive).
X
X} [count] paragraphs forward (exclusive).
X
X]] [count] sections forward or to the next <{> in the
X first column. When used after an operator, then the
X <}> in the first column. (linewise).
X
X][ [count] sections forward or to the next <}> in the
X first column (linewise).
X
X[[ [count] sections backward or to the previous <{> in
X the first column (linewise).
X
X[] [count] sections backward or to the previous <}> in
X the first column (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. Note that
Xthis does not include a <{> or <}> in the first column.
X
XA section begins after a form-feed in the first column and at each of a set
Xof section macros, specified by the pairs of characters in the 'sections'
Xoption. The default is "SHNHH HUnhsh".
X
XThe "]" and "[" commands stop at the <{> or <}" in the first column. This is
Xuseful to find the start or end of a function in a C program. Note that the
Xfirst character of the command determines the search direction and the
Xsecond character the type of brace found.
X
X
X6.5 Pattern searches
X
X/{pattern}[/] Search forward for the [count]'th occurrence of
X {pattern} (exclusive).
X
X/{pattern}/{offset} Search forward for the [count]'th occurrence of
X {pattern} and go {offset} lines up or down (see
X below). (linewise).
X
X/ Search forward for the [count]'th latest used
X pattern with latest used {offset}.
X
X//{offset} Search forward for the [count]'th latest used
X pattern with new {offset}. If {offset} is empty no
X offset is used.
X
X* Search forward for the [count]'th occurrence of the
X ident after or under the cursor (exclusive). {not in
X Vi}
X
X# Search backward for the [count]'th occurrence of the
X ident after or under the cursor (exclusive). {not in
X Vi}
X
X?{pattern}[?] Search backward for the [count]'th previous
X occurrence of {pattern} (exclusive).
X
X?{pattern}?{offset} Search backward for the [count]'th previous
X occurrence of {pattern} and go {offset} lines up or
X down (see below) (linewise).
X
X? Search backward for the [count]'th latest used
X pattern with latest used {offset}.
X
X??{offset} Search backward for the [count]'th latest used
X pattern with new {offset}. If {offset} is empty no
X offset is used.
X
Xn Repeat the latest "/" or "?" [count] times. {Vi: no
X count}
X
XN Repeat the latest "/" or "?" [count] times in
X opposite 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 internally for the :tags command)
X
XIf a <-> or <+> is given but [num] is omitted, a count of one will be used.
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 (search to the
Xleft and up) and the "*" is under your right hand middle finger (search to
Xthe right and down).
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. Example: "foo\|bar" matches "foo" and
X "bar.
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. Example: "foo[0-9]bar",
X first match "foo", then a digit and then "bar".
X
X3. A piece is an atom, possibly followed by:
X 'magic' 'nomagic'
X option option
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 Examples:
X .* .\* match anything, also empty string
X .\+ .\+ match any non-empty string
X foo\? foo\? match "fo" and "foo"
X
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
XIt is impossible to have a pattern that contains a line break.
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
XTechnical detail:
X<NUL> characters in the file are stored as <LF> in memory. In the display
Xthey are shown as "^@". The translation is done when reading and writing
Xfiles. To match a <NUL> with a search pattern you can just enter CTRL-@ or
X"CTRL-V 000". This is probably just what you expect. Internally the
Xcharacter is replaced by a <LF> in the search pattern. What is unusual is
Xthat typing CTRL_V CTRL_J also inserts a <LF>, thus also searches for a
X<NUL> in the file. {vi cannot handle <NUL> characters in the file at all}
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 <t>. 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 Visual mode. These commands do not work when no
Xoperator or put command has been used yet in the current file. The position
Xmay be incorrect 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", "L", "M", "H" and
Xthe commands that start editing a new file. If you make the cursor "jump"
Xwith one of these commands, the position of the cursor before the jump is
Xremembered. You can return to that position with the "''" and "``" command,
Xunless the line containing that position was changed or deleted.
X
XCTRL-O Go to [count] Older cursor position in jump list
X (not a motion command). {not in Vi}
X
XCTRL-I Go to [count] 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). Parens
X and braces preceded with a backslash are ignored.
X Parens and braces inside quotes are ignored, unless
X the number of parens/braces in a line is uneven and
X this line and the previous one does not end in a
X backslash. No count is allowed ({count}% jumps to a
X line {count} percentage down the file).
X
XH To line [count] 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 [count] 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
XMove edit window downwards (this means that more lines downwards in the text
Xbuffer are seen):
X
XCTRL-E Window [count] lines downwards in the buffer
X
XCTRL-D Window Downwards in the buffer. The number of lines
X comes from the 'scroll' option (default: half a
X screen). If [count] given, first set 'scroll' option
X to [count].
X
X<SC_DOWN> or
XCTRL-F Window [count] pages Forwards (downwards) in the
X buffer.
X
XMove edit window upwards (this means that more lines upwards in the text
Xbuffer are seen):
X
XCTRL-Y Window [count] lines upwards in the buffer.
X
XCTRL-U Window Upwards in the buffer. The number of lines
X comes from the 'scroll' option (default: half a
X screen). If [count] given, first set 'scroll' option
X to [count].
X
X<SC_UP> or
XCTRL-B Window [count] pages Backwards (upwards) in the
X buffer.
X
XWindow repositioning:
X
Xz<CR> Redraw, line [count] at top of window (default
X cursor line).
X
Xz{height}<CR> Redraw, make window {height} lines tall. This is
X useful to make the number of lines small when screen
X updating is very slow. Cannot make the height more
X than the physical screen height.
X
Xz. Redraw, line [count] at center of window (default
X cursor line).
X
Xz- Redraw, line [count] 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 [count] older entry in the tag stack
X (default 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-----------------------------------------------------------------------------
END_OF_FILE
if test 45369 -ne `wc -c <'vim/doc/reference.do2'`; then
echo shar: \"'vim/doc/reference.do2'\" unpacked with wrong size!
fi
chmod +x 'vim/doc/reference.do2'
# end of 'vim/doc/reference.do2'
fi
echo shar: End of archive 22 \(of 25\).
cp /dev/null ark22isdone
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...