next up previous contents
Next: VI quirks Up: Creating And Editing Files Previous: Using VI

VI User Variables

vi has a series of variables that can be set to customize it. To see these variables while editing a document, give the command ':set all '. This will cause a list of the variables to be displayed on the screen. Variables are set with the ':set' command followed by the variable you wish to change. Some variables are set equal to a value, as with the marginlength setting below, while some, like the autoindent feature, are either on or off.

To change the default word wrap margin:

:set wm =<marginlength><CR>

To change the default setting for autoindentation (a useful feature to enable while programming):

:set ai <CR>

To turn off a boolean option, set the variable again as no<variablename> .

To change the shift-width variable, which is used with the <<,>> commands:

:set sw =<shiftwidth><CR>

These commands can be performed every time you start vi by setting the variables within the vi initialization file .exrc in your home directory. A typical setup as written in the .exrc file is shown below:

set autoindent
set nowrapscan
set shiftwidth=4
set modeline
set showmode
set report=1
set novice
set noterse
set wrapmargin=10
For more information on these, and other vi variables, issue man vi .


next up previous contents
Next: VI quirks Up: Creating And Editing Files Previous: Using VI
World Wide Web Administrator
1/5/1999