Configuring vi
vi has a number of internal variables. These can be configured
by typing the :setvarname command, where
varname is the name of the variable to change.
To examine vi's current settings, go to command
mode and type :set all.
If a variable name starts with ``no'', it is not set (that is, not
switched on). You can set it by typing :set varname,
with an optional value. If a variable name does not start
with ``no'', and is not followed by a number, it is set. You can
switch it off by issuing a command like
:set novarname. For example,
to make vi ignore wildcards, you must switch
off the variable ``magic''. To do this, type :set nomagic.
To make vi automatically begin a new line
before you reach the right-hand side of the screen, type
:set wrapmargin=15.
The first word that is less than fifteen
characters from the right-hand side of the screen
is placed on a new line. (If you
have used word processors, this feature may be known to
you as ``word wrap''.)
Here are some of the most useful vi settings. Some of
them can be abbreviated; for example, typing :set
autowrite and :set aw have the same effect.
number-
Displays line numbers at the left-hand edge of the screen. (The numbers
are not part of the saved file). You can go to any line by
going to command mode and entering the line number followed by
G. (This setting can be abbreviated to nu.)
autoindent-
Indents the left-hand margin of new lines of text by an amount
determined from the previous line of text. For example, if you indent a
line by one tab, vi will automatically indent all
subsequent lines by the same distance until you cancel the
previous indent by pressing <Ctrl>D. (This setting can be
abbreviated to ai.)
autowrite-
Saves any changes that have been made to the current file
when you issue a :n, :rew,
or :! command.
(This setting can be abbreviated to aw.)
ignorecase-
Ignores the case of text while searching.
(This setting can be abbreviated to ic.)
list-
Prints end-of-line characters as ``$'', and tab characters as
``^I''. These characters are normally invisible.
showmode-
Displays a message at the bottom right of the screen when you
switch to a text input mode.
tabstop-
Sets the number of spaces between each tab stop
on the screen. When you press
the <Tab> key in insertion mode, you are inserting a
special tab character into your text. vi
interprets this as a command to replace the tab character with
however many spaces are needed to bring the cursor into line with
the next tab stop position. vi normally puts tab stops
eight characters apart; by using :set
tabstop=number you can change the number of
characters between tabs. This is useful for adjusting the width of columns
of text or levels of indentation in documents created using tabs instead of
spaces. (This setting can be abbreviated to ts.)
A complete list of the internal vi variables and their
meanings is included in
vi(C).
You can create a list of these variables that are automatically
set whenever you start vi as described in the following
section.
Next topic:
Saving frequently used commands
Previous topic:
Changing modes within a mapped command
© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003