Vim (for Vi Improved) is a screen-oriented text editor originally created for the Unix operating system. This guide install a configured Vim as the default system editor.
This howto is tested on:
- Debian 10.0 Buster
Installation
Detect if sudo is available (“command” is used if not):
cmdProxy='command'
command type -f 'sudo' &>'/dev/null' && cmdProxy='sudo'
Environment setup
Install the software
${cmdProxy} apt install 'vim'
Configuration
Define Vim default configuration:
vimConfig='" List mode: special characters are visible, line break is visible as $.
set list
" Enable line numbering.
set number
" Expand tabulations to spaces.
set expandtab
" Tabulation is displayed by a 2 characters blank space.
set tabstop=2
" Tabulation is replaced by 2 spaces characters.
set softtabstop=2
" Indentation width is 2 spaces.
set shiftwidth=2
" Do not create backup of edited files (prevent clutter).
set nobackup
" Use utf-8 encoding for edition.
set encoding=utf-8
" Store file with utf-8 encoding.
set fileencoding=utf-8
" Enable syntax colorization.
syn on'
Apply Vim default configuration for current user and root user:
command tee -a "${HOME}/.vimrc" <<< "${vimConfig}"
[ "${USER}" != "root" ] && ${cmdProxy} tee -a "/root/.vimrc" <<< "${vimConfig}"
Set Vim as the system’s default editor:
${cmdProxy} update-alternatives --set 'editor' "$(command -v 'vim.basic')"
Learn to use Vim with:
command vimtutor
Bibliography
- vi and Vim Editors Pocket Reference.
- Practical Vim: Edit Text at the Speed of Thought.
- Modern Vim: Craft Your Development Environment with Vim 8 and Neovim.
- Mastering Vim: Build a software development environment with Vim and Neovim.
Thanks
- Thanks to Vim (en) developers.
0 Comments