/etc/vimrc, ~/.vimrc

The LFS book installs vim as its text editor. At this point we should state that there are a lot of different editing applications 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 a slightly expanded vimrc that you can put in /etc/vimrc to provide global effect. Of course, if you put it into /etc/skel/.vimrc instead, it will be made available to users you add to the system later. You can also copy the file from /etc/skel/.vimrc to /etc/vimrc and the home directory of users already on the system, like root. Be sure to set permissions, owner, and group if you do copy anything directly from /etc/skel.

" Begin .vimrc

set nocompatible
set bs=2
set columns=80
set background=dark
set wrapmargin=8
syntax on
set ruler

" End .vimrc

A FAQ on the lfs mailing 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:

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.