10.87.1. Installation of Vim
The following patch merges all updates from the 7.3 Branch
from the Vim developers:
patch -Np1 -i ../vim-7.3-branch_update-2.patch
Change the default location of
the vimrc
configuration file to /etc
:
echo '#define SYS_VIMRC_FILE "/etc/vimrc"' >> src/feature.h
Prepare Vim for compilation:
CC="gcc ${BUILD64}" CXX="g++ ${BUILD64}" \
./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 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 accustomed to using vi
instead of vim. Some programs, such as
vigr and vipw, also use
vi. Create a symlink to permit execution of
vim when users habitually enter vi
and allow programs that use vi to work:
ln -sv vim /usr/bin/vi
By default, Vim's documentation is installed in
/usr/share/vim
. The following symlink
allows the documentation to be accessed via
/usr/share/doc/vim-7.3
, making
it consistent with the location of documentation for other packages:
ln -sv ../vim/vim73/doc /usr/share/doc/vim-7.3
If an X Window System is going to be installed on the CLFS
system, you may want 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, refer to the
Vim documentation and the Vim installation page in CBLFS at http://cblfs.cross-lfs.org/index.php/Vim.
10.87.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
set ruler
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'