#### Linux From Scratch - Version 7.9

### Chapter 6. Installing Basic System Software

- Prev

  Man-DB-2.7.5

- Next

  About Debugging Symbols

- Up
- Home

# 6.70. Vim-7.4

The Vim package contains a powerful text editor.

Approximate build time: 1.0 SBU
Required disk space: 111 MB

### Alternatives to Vim

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

## 6.70.1. Installation of Vim

First, 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:

    ./configure --prefix=/usr

Compile the package:

    make

To test the results, issue:

    make -j1 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. A successful test will result in the words "ALL DONE" at completion.

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 for both the binary and the man page in the provided languages:

    ln -sv vim /usr/bin/vi
    for L in  /usr/share/man/{,*/}man1/vim.1; do
        ln -sv vim.1 $(dirname $L)/vi.1
    done

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.4`, making it consistent with the location of documentation for other packages:

    ln -sv ../vim/vim74/doc /usr/share/doc/vim-7.4

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/7.9/postlfs/vim.html.

## 6.70.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` setting 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` setting allows backspacing over line breaks, autoindents, and the start of insert. The `syntax on` parameter enables vim's syntax highlighting. Finally, the if statement with the `set background=dark` setting 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'

### Note

By default, Vim only installs spell files for the English language. To install spell files for your preferred language, download the `*.spl` and optionally, the `*.sug` files for your language and character encoding from ftp://ftp.vim.org/pub/vim/runtime/spell/ and save them to `/usr/share/vim/vim74/spell/`.

To use these spell files, some configuration in `/etc/vimrc` is needed, e.g.:

    set spelllang=en,ru
    set spell

For more information, see the appropriate README file located at the URL above.

## 6.70.3. Contents of Vim

Installed programs: ex (link to vim), rview (link to vim), rvim (link to vim), vi (link to vim), view (link to vim), vim, vimdiff (link to vim), vimtutor, and xxd
Installed directory: /usr/share/vim

### Short Descriptions

ex | Starts vim in ex mode
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
vi | Link to vim
view | Starts vim in read-only mode
vim | Is the editor
vimdiff | Edits two or three versions of a file with vim and show differences
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

- Prev

  Man-DB-2.7.5

- Next

  About Debugging Symbols

- Up
- Home