start page | rating of books | rating of authors | reviews | copyrights

Learning the vi Editor

Learning the vi EditorSearch this book
Previous: 11.1 Author and HistoryChapter 11
vim -- vi Improved
Next: 11.3 Online Help and Other Documentation
 

11.2 Important Command-Line Arguments

vim looks at how it was invoked to decide how it should behave. If invoked as ex, it will operate as a line editor. It also allows the Q command from vi mode to switch into ex mode. If invoked as view, it will start in vi mode, but mark each file initially as being read-only.

When invoked as gvim or gview, vim will start the GUI version, under X Windows or in whatever other graphical interface is appropriate. If a leading r is prepended to any of the names, vim enters "restricted" mode, where certain actions are disabled.

vim has a large number of command-line options. The most useful are described here:

-c command

Execute command upon startup. This is the POSIX version of the historical +command syntax, but vim is not limited to positioning commands. (The old syntax is also accepted.) You can give up to ten -c commands.

-R

Start in read-only mode, setting the readonly option.

-r

Recover specified files, or if no files are listed on the command line, list all the files that can be recovered.

-s

Enter batch (script) mode. This is only for ex, and is intended for running editing scripts. This is the POSIX version of the historic "-" argument.

-b

Start in binary mode. This sets a few options that make it possible to edit a binary file.

-f

For the GUI version, stay in the foreground. This should be used by programs that invoke vim and wait for it to finish, such as mail handling programs.

-g

Start the GUI version of vim, if it has been compiled in.

-o [N]

Open N windows, if given, otherwise open one window for each file argument.

-i viminfo

Read the given viminfo file for initialization, instead of the default viminfo file.

-n

Do not create a swap file. Recovery will not be possible, but this is useful for editing files on slow media, such as floppies.

-q filename

Treat filename as the "quick fix" file. This file should contain a list of error messages that vim will use for navigating to the location of each error in your program. Quick fix mode is discussed in Section 11.9.1, "Edit-Compile Speedup".

-u vimrc

Read the given vimrc file for initialization, and skip all other normal initialization steps.

-U gvimrc

Read the given gvimrc file for GUI initialization, and skip all other normal GUI initialization steps.

-Z

Enter restricted mode (same as having a leading r in the name). You cannot start shell commands or suspend the editor when this is in effect.

The -i, -n, -u and -U options are discussed in more detail below. There are several more options; the interested reader is referred to the online documentation for the full details.


Previous: 11.1 Author and HistoryLearning the vi EditorNext: 11.3 Online Help and Other Documentation
11.1 Author and HistoryBook Index11.3 Online Help and Other Documentation

The UNIX CD Bookshelf NavigationThe UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System