Customizing vi
vi
operates differently on various terminals. On modern Unix systems, vi gets
operating instructions about your terminal type from the terminfo
terminal database. (On older
systems, vi uses the original
termcap
database.)[29]
There are also a number of options that you can set from within vi that affect how it operates. For example, you can set a right margin that will cause vi to wrap lines automatically, so you don’t need to hit ENTER.
You can change options from within vi by using the ex command :set
. In addition, whenever vi is started up, it reads a file in your
home directory called .exrc for further operating instructions.
By placing :set
commands in this
file, you can modify the way vi
acts whenever you use it.
You can also set up .exrc files in local directories to initialize various options that you want to use in different environments. For example, you might define one set of options for editing English text, but another set for editing source programs. The .exrc file in your home directory will be executed first, and then the one in your current directory.
Finally, any commands stored in the environment
variable EXINIT
will be executed by
vi on startup. The settings in
EXINIT
take precedence over those
in the home directory.exrc file.
The :set Command
There are two types of options that can be changed
with the :set
command: toggle options, which are either on or off, and options that take a numeric or string value (such as the location of a margin or the ...
Get Learning the vi and Vim Editors, 7th 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.