11.2. vi Command-Line Options
The three most common ways of starting
a vi
session are:
vi file
vi +n file
vi +/ pattern file
You can open file for editing, optionally at
line n or at the first line matching
pattern. If no file is
specified, vi opens with an empty
buffer. The command-line options that can be used with vi are as follows (vim-only options are labeled):
- +[num]
-
Start editing at line number num, or the last
line of the file if num is omitted.
- +/pattern
-
Start editing at the first line matching
pattern. (Fails if nowrapscan is set in your
.exrc startup file.)
- -b
-
Edit the file in binary mode. {vim}
- -c command
-
Run the given vi command upon
startup. Only one -c option is
permitted. ex commands can be
invoked by prefixing them with a colon. An older form of this option,
+command, is
still supported.
- --cmd command
-
Like -c, but execute the command
before any resource files are read. {vim}
- -d
-
Run in diff mode. Works like vimdiff. {vim}
- -e
-
Run as ex (line editing rather than
full-screen mode).
- -h
-
Print help message, then exit.
- -i file
-
Use the specified file instead of the default
.viminfo to save or restore vim's state. {vim}
- -l
-
Enter LISP mode for running LISP programs (not supported in all
versions).
- -m
-
Start the editor with the write
option turned off so the user cannot write to files. {vim}
- -n
-
Do not use a swap file; record changes in memory only. {vim}
- --noplugin
-
Do not load any plug-ins. {vim}
- -o[n]
-
Start vim with
n open windows. The default is to open one
window for each file. {vim}
- -r [file]
-
Recovery mode; recover and resume editing on
file after an aborted editor session or system
crash. Without file, list files available for
recovery.
- -s, -s scriptfile
-
When running in ex mode (-e), suppress prompts or informative messages
sent to the console. Otherwise, read and execute commands given in
the specified scriptfile as if they were typed
in from the keyboard. {vim}
- -t tag
-
Edit the file containing tag and position the
cursor at its definition. (See ctags
in Chapter 3 for more information.)
- -u file
-
Read configuration information from the specified resource file
instead of default .vimrc resource files. If the
file argument is NONE, vim
will read no resource files, load no plug-ins, and run in compatible
mode. If the argument is NORC, it
will read no resource files but it will load plug-ins. {vim}
- -v
-
Run in full-screen mode (default).
- --version
-
Print version information, then exit.
- -w rows
-
Set the window size so rows lines at a time are
displayed; useful when editing over a slow dial-up line.
- -x
-
Prompt for a key that will be used to try to encrypt or decrypt a
file using crypt (not supported in
all versions).
- -y
-
Modeless vi; run vim in insert mode only, without a command
mode. This is the same as invoking vim as evim.
{vim}
- -C
-
Same as -x, but assume the file is
encrypted already (not supported in all versions). For vim this option starts the editor in vi-compatible mode.
- -D
-
Debugging mode for use with scripts. {vim}
- -L
-
List files that were saved due to an aborted editor session or system
crash (not supported in all versions). For vim this option is the same as -r.
- -M
-
Do not allow text in files to be modified. {vim}
- -N
-
Run vim in a non-vi-compatible mode. {vim}
- -O[n]
-
Start vim with
n open windows arranged vertically on the
screen. {vim}
- -R
-
Edit files read-only.
- -S commandfile
-
Source commands given in commandfile after
loading any files for editing specified on the command line.
Shorthand for the option -c source.
{vim}
- -T type
-
Set the terminal type. This value overrides the $TERM environment variable. {vim}
- -V[n]
-
Verbose mode; print messages about what options are being set and
what files are being read or written. You can set a level of
verbosity to increase or decrease the number of messages received.
The default value is 10 for high verbosity. {vim}
- -W scriptfile
-
Write all typed commands from the current session to the specified
scriptfile. The file created can be used with
the -s command. {vim}
- -Z
-
Start vim in restricted mode. Do not
allow shell commands or suspension of the editor. {vim}
| | | 11. The vi Editor | | 11.3. ex Command-Line Options |
Copyright © 2003 O'Reilly & Associates. All rights reserved.
|
|