6.23. Vim-6.3

The Vim package contains a powerful text editor.

Approximate build time: 0.4 SBU
Required disk space: 38.0 MB
Installation depends on: Bash, Binutils, Coreutils, Diffutils, GCC, Glibc, Grep, Make, Ncurses, and Sed
[Tip]

Alternatives to Vim

If you prefer another editor—such as Emacs, Joe, or Nano—please refer to http://www.linuxfromscratch.org/blfs/view/svn/postlfs/editors.html for suggested installation instructions.

6.23.1. Installation of Vim

First, unpack both vim-6.3.tar.bz2 and (optionally) vim-6.3-lang.tar.gz archives into the same directory. Then, change the default location of the vimrc configuration file to /etc:

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

Vim has two known security vulnerabilities that have already been addressed upstream. The following patch fixes the problems:

patch -Np1 -i ../vim-6.3-security_fix-2.patch

Now prepare Vim for compilation:

./configure --prefix=/usr --enable-multibyte

The meaning of the configure options:

--enable-multibyte

This optional but highly recommended switch enables support for editing files in multibyte character encodings. This is needed if using a locale with a multibyte character set. This switch is also helpful to be able to edit text files initially created in Linux distributions like Fedora Core that use UTF-8 as a default character set.

Compile the package:

make

To test the results, issue: make test. However, this test suite outputs a lot of binary data to the screen, which can cause issues with the settings of the current terminal. This can be resolved by redirecting the output to a log file.

Install the package:

make install

Many users are used to using vi instead of vim. To allow execution of vim when users habitually enter vi, create a symlink:

ln -sv vim /usr/bin/vi

If an X Window System is going to be installed on the LFS system, it may be necessary to recompile Vim after installing X. Vim comes with a GUI version of the editor that requires X and some additional libraries to be installed. For more information on this process, refer to the Vim documentation and the Vim installation page in the BLFS book at http://www.linuxfromscratch.org/blfs/view/svn/postlfs/editors.html#postlfs-editors-vim.

6.23.2. Configuring Vim

By default, vim runs in vi-incompatible mode. This may be new to users who have used other editors in the past. The “nocompatible” setting is included below to highlight the fact that a new behavior is being used. It also reminds those who would change to “compatible” mode that it should be the first setting in the configuration file. This is necessary 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
if (&term == "iterm") || (&term == "putty")
  set background=dark
endif

" 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” to keep 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 syntax highlighting. Finally, the if statement with the set background=dark corrects vim's guess about the background color of some terminal emulators. This gives the highlighting a better color scheme for use on the black background of these programs.

Documentation for other available options can be obtained by running the following command:

vim -c ':options'

6.23.3. 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

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

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 cannot be suspended

rvim

Is a restricted version of vim; no shell commands can be started and vim cannot be suspended

shtags.pl

Generates a tags file for Perl scripts

tcltags

Generates a tags file for TCL code

view

Starts vim in read-only mode

vi

Is the editor

vim

Is the editor

vim132

Starts vim with the terminal in 132-column mode

vim2html.pl

Converts Vim documentation to HypterText Markup Language (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

Spell checks a file and generates the syntax statements necessary to highlight in vim. This script requires the old Unix spell command, which is provided neither in LFS nor in BLFS

vimtutor

Teaches the basic keys and commands of vim

xxd

Creates a hex dump of the given file; it can also do the reverse, so it can be used for binary patching