Vim-6.2

The Vim package contains a powerful text editor.

Approximate build time:  0.4 SBU
Required disk space:     34 MB

Vim installation depends on: Bash, Binutils, Coreutils, Diffutils, GCC, Glibc, Grep, Make, Ncurses, Sed.

Alternatives to Vim

If you prefer another editor -- like Emacs, Joe, or Nano -- to Vim, have a look at http://www.linuxfromscratch.org/blfs/view/stable/postlfs/editors.html for suggested installation instructions.

Installation of Vim

First change the default locations of the vimrc and gvimrc configuration files to /etc.

echo '#define SYS_VIMRC_FILE "/etc/vimrc"' >> src/feature.h
echo '#define SYS_GVIMRC_FILE "/etc/gvimrc"' >> src/feature.h

Now prepare Vim for compilation:

./configure --prefix=/usr

Compile the package:

make

To test the results, you can issue: make check. However, this test suite outputs a lot of seemingly garbage characters to the screen, and this can wreak havoc with the settings of the current terminal. Therefore the running of the test suite here is strictly optional.

Now install the package:

make install

Many users are used to using vi, instead of vim. To let them execute vim when they habitually enter vi, create a symlink:

ln -s vim /usr/bin/vi

If you are going to install the X Window system on your LFS system, you may want to re-compile Vim after having installed X. Vim comes with a nice GUI version of the editor that requires X and a few other libraries to be installed. For more information read the Vim documentation.

Configuring Vim

By default, vim runs in vi-incompatible mode. Some people might not like this, but we prefer to run vim in its own mode (else we wouldn't have included it in this book, but the original vi). We've included the setting of "nocompatible" below to high-light the fact that the new behavior is being used. It also reminds those who would change to "compatible" mode that it should appear first because it changes other settings and overrides must come after this setting. Create a default vim configuration file by running the following:

cat > /etc/vimrc << "EOF"
" Begin /etc/vimrc

set nocompatible
set backspace=2
syntax on

" End /etc/vimrc
EOF

The set nocompatible makes vim behave in a more useful way (the default) than the vi-compatible manner. Remove the "no" if you want the old vi behavior. The set backspace=2 allows backspacing over line breaks, autoindents and the start of insert. The syntax on enables vim's semantic coloring.

Contents of Vim

Installed programs: efm_filter.pl, efm_perl.pl, ex (link to vim), less.sh, mve.awk, pltags.pl, ref, rview (link to vim), rvim (link to vim), shtags.pl, tcltags, vi (link to vim), view (link to vim), vim, vim132, vim2html.pl, vimdiff (link to vim), vimm, vimspell.sh, vimtutor and xxd

Short descriptions

efm_filter.pl is a filter for creating an error file that can be read by vim.

efm_perl.pl reformats the error messages of the Perl interpreter for use with the “quickfix” mode of vim.

ex starts vim in ex mode.

less.sh is a script that starts vim with less.vim.

mve.awk processes vim errors.

pltags.pl creates a tags file for perl code, for use by vim.

ref checks the spelling of arguments.

rview is a restricted version of view: no shell commands can be started and view can't be suspended.

rvim is a restricted version of vim: no shell commands can be started and vim can't be suspended.

shtags.pl generates a tag file for perl scripts.

tcltags generates a tag file for TCL code.

view starts vim in read-only mode.

vim is the editor.

vim132 starts vim with the terminal in 132-column mode.

vim2html.pl converts vim documentation to HTML.

vimdiff edits two or three versions of a file with vim and show differences.

vimm enables the DEC locator input model on a remote terminal.

vimspell.sh is a script which spells a file and generates the syntax statements necessary to highlight in vim.

vimtutor teaches you the basic keys and commands of vim.

xxd makes a hex dump of the given file. It can also do the reverse, so it can be used for binary patching.