Sunday, April 17, 2005

Setting up Vim (.vimrc)

vi has a large set of options that can be set to alter the behaviour of the editor. Vim expands on this set. I have listed only those that are most important to a beginning user.
Options are set by typing :set >option<>option< is the name of the option. There are two kinds of options: boolean options (those which can be either on or off) and variable options (those which take a value). In vim, :help options will provide quite a nice summary of the options.

Options may either be set on the fly while running vi, or they may be read from a configuration file called .exrc, .vimrc, or .gvimrc. :set all will show you the current setting of every option. Option name Description Example
autoindent sets autoindenting on :set autoindent
backup Causes vim to save a copy of the file with a ~ on the end without the changes you just made :set backup
tabstop Determines the width of the tab character :set tabstop=4
ruler Shows cursor position on the modeline :set ruler
wrap Determines whether a line exceeding the width of the display will wrap to the next line :set wrap
showbreak Sets which characters(if any) will appear in front of the second portion of the wrapped line :set showbreak=>
showmode Displays the mode on the modeline when not in command mode :set showmode
fileformat Sets the end of line character used when the file is saved :set fileformat=dos

sample .vimrc file:

:set tabstop=4
Post a Comment