< Previous | Contents | Next >
6.71.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
" Ensure defaults are set before customizing settings, not after source $VIMRUNTIME/defaults.vim
let skip_defaults_vim=1
set nocompatible set backspace=2 set mouse= syntax on
if (&term == "xterm") || (&term == "putty") set background=dark
endif
" End /etc/vimrc
EOF
cat > /etc/vimrc << "EOF"
" Begin /etc/vimrc
" Ensure defaults are set before customizing settings, not after source $VIMRUNTIME/defaults.vim
let skip_defaults_vim=1
set nocompatible set backspace=2 set mouse= syntax on
if (&term == "xterm") || (&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. The set mouse= setting enables proper pasting of text with the mouse when working in chroot or over a remote connection. 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'
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/vim81/spell/.
To use these spell files, some configuration in /etc/vimrc is needed, e.g.:
For more information, see the appropriate README file located at the URL above.
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/vim81/spell/.
To use these spell files, some configuration in /etc/vimrc is needed, e.g.:
For more information, see the appropriate README file located at the URL above.
set spelllang=en,ru set spell
set spelllang=en,ru set spell