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):
Start editing at line number num , or the last line of the file if num is omitted.
Start editing at the first line matching pattern . (Fails if nowrapscan is set in your .exrc startup file.)
Edit the file in binary mode. ( vim )
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.
Like -c , but execute the command before any resource files are read. ( vim )
Run in diff mode. Works like vimdiff . ( vim )
Run as ex (line editing rather than full-screen mode).
Print help message, then exit.
Use the specified file instead of the default .viminfo to save or restore vim 's state. ( vim )
Enter LISP mode for running LISP programs (not supported in all versions).
Start the editor with the write option turned off so the user can't write to files. ( vim )
Don't use a swap file; record changes in memory only. ( vim )
Don't load any plug-ins. ( vim )
Start vim with n open horizontal windows . The default is to open one window for each file. ( vim )
Recovery mode; recover and resume editing on file after an aborted editor session or system crash. Without file, list files available for recovery.
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 )
Edit the file containing tag and position the cursor at its definition.
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 )
Run in full-screen mode (default).
Print version information, then exit.
Set the window size so rows lines at a time are displayed; useful when editing over a slow dial-up line.
Prompt for a key that will be used to try to encrypt or decrypt a file using crypt (not supported in all versions).
Modeless vi ; run vim in insert mode only, without a command mode. This is the same as invoking vim as evim . ( vim )
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.
Debugging mode for use with scripts. ( vim )
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 .
Don't allow text in files to be modified. ( vim )
Run vim in a non- vi -compatible mode. ( vim )
Start vim with n open windows arranged vertically on the screen. ( vim )
Edit files read-only.
Source commands given in commandfile after loading any files for editing specified on the command line. Shorthand for the option -c source. ( vim )
Set the terminal type . This value overrides the $ TERM environment variable. ( vim )
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 )
Write all typed commands from the current session to the specified scriptfile . The file created can be used with the -s command. ( vim )
Start vim in restricted mode. Don't allow shell commands or suspension of the editor. ( vim )