Command-Line Syntax
The three most common ways of starting a vi session are:
vi [options]filevi [options] +num filevi [options] +/pattern file
You can open file for editing, optionally at line num or at the first line matching pattern. If no file is specified, vi opens with an empty buffer.
Command-Line Options
Because vi and ex are the same program, they share the same options. However, some options only make sense for one version of the program. Options specific to Vim are so marked:
+[num]Start editing at line number num, or the last line of the file if num is omitted.
+/patternStart editing at the first line matching pattern. (For ex, this fails if
nowrapscanis set in your .exrc startup file, since ex starts editing at the last line of a file.)+?patternStart editing at the last line matching pattern.
-bEdit the file in binary mode. {Vim}
-ccommandRun the given ex command upon startup. Only one
-coption is permitted for vi; Vim accepts up to 10. An older form of this option,+command, is still supported.--cmdcommandLike
-c, but execute the command before any resource files are read. {Vim}-CSolaris vi: same as
-x, but assume the file is encrypted already.Vim: start the editor in vi-compatible mode.
-dRun in diff mode. Works like vimdiff. {Vim}
-DDebugging mode for use with scripts. {Vim}
-eRun as ex (line-editing rather than full-screen mode).
-hPrint help message, then exit. {Vim}
-ifileUse the specified file instead of the default (~/.viminfo) to save or restore Vim’s state. ...