/etc/vimrc, ~/.vimrc
The LFS book installs vim as its editor. At this point we should
state that there are a lot of different editors out
there including emacs, nano, joe and many more. Anyone who has been
around the Internet (especially usenet) for a short time will certainly
have observed at least one flame war, usually involving vim and emacs
users!
The LFS book gives a basic vimrc file. Here,
we attempt to enhance this file. At startup, vim reads
/etc/vimrc and ~/.vimrc
(i.e., the global vimrc and the user-specific one.). Note that this is
only true if you compiled vim using LFS-3.1 onwards. Prior to this,
the global vimrc was /usr/share/vim/vimrc.
Here is an example of a slightly expanded vimrc:
" Begin .vimrc
set nocompatible
set bs=2
set columns=80
set background=dark
set tabstop=8
set wrapmargin=8
set nobk
syntax on
set ruler
set noexpandtab
" End .vimrc
A FAQ on the lfs lists regards the comment tags in vimrc. Note
that they are " instead of the more usual # or //. This is correct, the
syntax for vimrc is slightly unusual.
We'll run through a quick explanation of what each of the
options in this example file means here:
set nocompatible :
This option stops vim from behaving in a strongly vi-compatible way. It
should be at the start of any vimrc file as it can affect lots of other
options which you may want to override.
set bs=2 :
This influences the behaviour of the backspace option. It is fairly
complex so see :help 'bs' for more
details.
set columns=80 :
This simply sets the number of columns used on the
screen.
set background=dark :
This tells vim to use colours which look good on a dark
background.
set tabstop=8 :
The number of spaces which a tabstop takes.
set wrapmargin=8 :
This is the number of characters from the right window
border where wrapping starts.
set nobk :
This stops vim from creating a backup before
overwriting a file.
syntax on :
Enables vim's syntax highlighting.
set ruler :
This makes vim show the current row and column at the bottom right of
the screen.
set noexpandtab :
This makes vim insert tabs as tab characters instead of as a set of
spaces.
More information on the many vim options
can be found by reading the help inside vim itself. Do this by typing
:help in vim to get the general help, or by
typing :help usr_toc.txt to view the User Manual
Table of Contents.