5.11 Configuring

   

5.11 Configuring vi Options

You can customize vi according to your requirements using vi environment options. Each option can be set in vi with the :set option command, where the word option is replaced with some valid option name . Options can also be unset using the same command and by adding no before the option name, like :set nooption .

You have already seen how you can tell vi to display line numbers with every line. For this you used the command :set number . A list of vi options is shown in Table 5-8.

Table 5-8. vi Options
Option Effect
:set number Sets line number in front of each line in vi .
:set all Lists all available options.
:set autoindent The next line is indented the same number of character as the current line.
:set readonly Sets the current file as read-only. No change is saved.
:set wrapmargin= n Sets the right wrap margin equal to n. If we are using 80-column display and the wrap margin is set to 6, every line will be wrapped to the next line after 74 characters .
:set showmode Shows the user when the user is in "insert mode," "replace one character mode," or "replace mode."

You can also use abbreviations for these commands. For example, you can use :se nu instead of :set number .

The vi editor has a configuration file with the name .exrc , which is stored in the home directory of each user. You can put vi options in this file to make the settings permanent. After creating this file, whenever you start the editor, it will first read the $HOME/.exrc file and set the options automatically. For example, if you are writing C programs, you may want to set autoindent and number every time you start editing a C program. You can create an .exrc file with the following two lines in it.

 se nu se ai 

Now these two settings are permanent until you make a change in the $HOME/.exrc file manually.


   
Top


HP Certified
HP Certified: HP-UX System Administration
ISBN: 0130183741
EAN: 2147483647
Year: 2000
Pages: 390
Authors: Rafeeq Rehman

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net