Editors Question:

How to create a .exrc file in vi editor?

Tweet Share WhatsApp

Answer:

This article presents a sample .exrc file that can be used
by users of the vi editor. The .exrc file, located in your
home directory, is the startup (or configuration) file for
the vi editor.

The intent of this brief article is to show some of the
ways you can modify the configuration of the vi editor



Please note that the .exrc file contains commands that Vi
reads when you first run it. The default directory that Vi
looks in for the .exrc file is your home directory.
However, if you run Vi from another directory containing
a .exrc file, Vi will use the .exrc in that directory and
bypass the home directory .exrc. You must precede control
characters (like ^[ or ^M) with CONTROL-V. For example to
enter ^M, type CONTROL-V CONTROL-M.


Some important points for .exrc files:

Do not allow any blank lines in the file or processing will
stop on that line.
Comments are introduced by starting a line with a double
quote: "
All directives, whether options, abbreviations, or key
macros must all be typed on a single line. The listing
below has had the lines broken up for the sake of
readability.
Control characters like [tab],[linefeed],[escape] can be
inserted by first typing ^V (hold down Ctrl, and press V),
followed by the character. For instance, for [tab], hold
Ctrl and press V, release Ctrl, hit [tab]. You'll see ^I.
This is evident in the listing below.
For VIM the corresponsing file is .vimrc (_vimrc in case of
windows).

Download Editors PDF Read All 18 Editors Questions
Previous QuestionNext Question
How to return to shell without leaving vi editor?What is the format of vi command?