home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam    

11.4 Initialization

This section describes vim 's initialization steps, including those taken for the GUI versions of vim .

11.4.1 Initialization for All vim Invocations

vim performs the following initialization steps:

  1. Set the shell and term options from the SHELL and TERM environment variables, respectively. On MS-DOS and Win32, use COMSPEC to set shell if SHELL is not set.

  2. If -u was supplied, execute the given file, and skip the rest of the startup file based initializations. The -s option has the same effect for ex mode; only the -u option will be interpreted. Use of -u NONE causes vim to skip all further initializations.

  3. Execute the system-wide vimrc file. The exact path is set when vim is compiled. A typical value is /usr/local/share/vim/vimrc .

  4. Execute instructions in the first place that exists of the following four:

    • The environment variable VIMINIT .

    • The user vimrc file, $HOME/.vimrc under UNIX (or Linux). The location will be different on non-UNIX systems. If .vimrc does not exist, vim looks for _vimrc . On the non-UNIX systems, the order is reversed.

    • The environment variable EXINIT .

    • The user exrc file, $HOME/.exrc . On non-UNIX systems, _exrc is tried. However, in this case, vim only looks for one or the other, not both.

  5. If the exrc option has been set, then vim looks in the current directory for the first file that exists of the following four. The others are ignored.

    • .vimrc

    • _vimrc

    • .exrc

    • _exrc

    On MS-DOS and Win32 systems, the _xxxrc files are looked for before the .xxxrc files.

  6. If they have not yet been set, the shellpipe and shellredir options are initialized based on the value of the shell option. The shellredir option is discussed in Section 11.9.1 .

  7. If -n was given on the command line, updatecount is set to zero. (This option controls how often the swap file is updated. The more often, the more the swap file is synchronized with all your changes, but possibly with decreased performance. Zero means never.)

  8. If -b was supplied, set the appropriate options for editing binary files.

  9. Perform GUI initializations. See the next subsection.

  10. If viminfo is set, read the file indicated there.

  11. If -q was supplied, read the named quick fix file. The quick fix facility is described in Section 11.9.1 .

  12. Open and fill all windows, as per the -o option. If -q was supplied, go to the first error.

  13. Jump to the tag given by the -t option, if supplied. Execute any commands given with -c .

That's a lot of steps. As in other areas, vim 's extra facilities also provide extra flexibility and customizability.

As for nvi , you can place common initialization actions into your .exrc file (i.e., options and commands for UNIX vi and/or the other clones), and have your .vimrc file execute :source .exrc before or after the vim -specific initializations.

The viminfo file is much like the elvis session file. It can be used to save a large part of the state of your editing session in between logins. The viminfo file stores the following items:

  • The command-line history

  • The search string history

  • Contents of registers

  • File marks, pointing to locations in files

  • Last search/substitute pattern (for n and & )

vim reads this file at startup, and when exiting, merges its current state with the contents of the file and then rewrites it.

11.4.2 Initialization for the GUI

If running the GUI version of vim , usually vim will fork a new process in order to run in the background, so that you can continue to give commands to the parent shell. The -f option disables this behavior.

If -U was supplied, vim executes the given file and skips the rest of the GUI startup file based initializations. Use of -U NONE causes vim to skip all further initializations.

Without -U , vim reads the system-wide gvimrc file (typically /usr/local/share/vim/ gvimrc ) and then the user gvimrc file, $HOME/.gvimrc .

These files can be used to configure the GUI. In particular, you can set up your own menus at this point.


Previous: 11.3 Online Help and Other Documentation Learning the vi Editor Next: 11.5 Multiwindow Editing
11.3 Online Help and Other Documentation Book Index 11.5 Multiwindow Editing

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










??????????????@Mail.ru