Initialization

vi performs the following initialization steps:

  1. If the EXINIT environment variable exists, execute the commands it contains. Separate multiple commands by a pipe symbol (|).

  2. If EXINIT doesn’t exist, look for the file $HOME/.exrc. If it exists, read and execute it.

  3. If either EXINIT or $HOME/.exrc turns on the exrc option, read and execute the file ./.exrc, if it exists.

  4. Execute search or goto commands given with +/pattern or +n command-line options (POSIX: -c option).

The .exrc files are simple scripts of ex commands; the commands in them don’t need a leading colon. You can put comments in your scripts by starting a line with a double quote ("). This is recommended.

Get vi and Vim Editors Pocket Reference, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.