Section 7.2. vi Command-Line Options

7.2. vi Command-Line Options

Here are the three most common ways to start a vi session:

 vi   file   vi +   n file   vi +/   pattern file   

You can open a 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 can't write to files. ( vim )



-n

Don't use a swap file; record changes in memory only. ( vim )



--noplugin

Don't load any plug-ins. ( vim )



-o[ n ]

Start vim with n open horizontal 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 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.



-u file

Read configuration information from file instead of default .vimrc resource files. If the file argument is NONE, vim won't read resource files, load plug-ins, or run in compatible mode. If the argument is NORC, it doesn't read 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

Don't 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. Don't allow shell commands or suspension of the editor. ( vim )



MAC OS X Tiger in a Nutshell
Mac OS X Tiger in a Nutshell: A Desktop Quick Reference (In a Nutshell (OReilly))
ISBN: 0596009437
EAN: 2147483647
Year: 2003
Pages: 130

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net