Table of Contents
VIM configuration
Make VI default editor
In order to make vi the standard global default editor to edit crontab for example use this command for debian:
update-alternatives --config editor
and select vim.basic
follow it by
select-editor
or
change the symlink to the default editor manually:
rm /etc/alternatives/editor ln -s /usr/bin/vi /etc/alternatives/editor
or
In order to make vi the global default editor in debian to edit crontab for example, either
vi /etc/bash.bashrc
and add this line at the end of the file:
export EDITOR=vi export VISUAL=vi
To make this change only for an individual user (whereby ~ is the home directory of the current user or change it to the home directory of the user this should be changed for):
vi ~/.bashrc
and add this line at the end of the file:
export VISUAL=vi export EDITOR=vi
Debian 9 VIM Mouse issues
In Debian 9, vi/vim has mouse support enabled by default. While this makes it easy to go to a different area of the file via mouse clicks, it causes copy&paste to fail and/or to behave weirdly.
To revert to the old behaviour, a local .vimrc file needs to be created. It can be empty (just containing a double quote sign which is a comment). When this file exists, the default config with mouse support (/usr/share/vim/vim80/defaults.vim
) is not being loaded. Editing the defaults.vim file directly is discouraged as this will be overwritten by updates.
vi ~/.vimrc
add something to it. In the very least one double quoted line as a comment:
"placeholder as /usr/share/vim/vim80/defaults.vim is loaded if no ~/.vimrc exists
Debian vim colour syntax highlighting
By default Debian installs vim-tiny which does not support syntax highlighting. To install all required modules for console use
apt-get install vim
then edit /etc/vim/vimrc
vi /etc/vim/vimrc
and enable syntax, dark backgrounds and remembering the previous cursor position by removing the double-quotes in front of the relevant lines like this:
" Vim5 and later versions support syntax highlighting. Uncommenting the next " line enables syntax highlighting by default. syntax on " If using a dark background within the editing area and syntax highlighting " turn on this option as well set background=dark
Good default configuration
Add the configuration to your local .vimrc file in your home directory for various sensible and convenient settings:
vi ~/.vimrc
"placeholder as /usr/share/vim/vim80/defaults.vim is loaded if no ~/.vimrc exists syntax on set tabstop=4 " The width of a TAB is set to 4. " Still it is a \t. It is just that " Vim will interpret it to be having " a width of 4. set shiftwidth=4 " Indents will have a width of 4 set softtabstop=4 " Sets the number of columns for a TAB set expandtab " Expand TABs to spaces set nocompatible " Fix telnet issues where cursor keys add A B etc set mouse-=a " Disable automatic visual mode when selecting with mouse " Only do this part when compiled with support for autocommands. if has("autocmd") " Enable file type detection. " Use the default filetype settings, so that mail gets 'tw' set to 72, " 'cindent' is on in C files, etc. " Also load indent files, to automatically do language-dependent indenting. " Revert with ":filetype off". filetype plugin indent on " Put these in an autocmd group, so that you can revert them with: " ":augroup vimStartup | au! | augroup END" augroup vimStartup au! " When editing a file, always jump to the last known cursor position. " Don't do it when the position is invalid or when inside an event handler " (happens when dropping a file on gvim). autocmd BufReadPost * \ if line("'\"") >= 1 && line("'\"") <= line("$") | \ exe "normal! g`\"" | \ endif augroup END endif " has("autocmd")