Some useful vim settings

Below is a list of some VIM settings I find useful. You can add them to your .vimrc.

source $VIMRUNTIME/mswin.vim                 " adds Ctrl-X, Ctrl-C, Ctrl-V; block visual mode is now Ctrl-Q
behave mswin

set autowriteall                             " autosave all files when a buffer is closed

set backupdir=~/.temp                        " dont pollute local directory with swap file, backup files etc
set dir=~/.temp

set undofile                                 " enable persistent undo
set undodir=~/.temp

set encoding=utf-8

set expandtab                                " replace tabs with spaces
set shiftwidth=2
set tabstop=2

set fileformats=unix,dos                     " prefer unix linebreaks, but also support DOS linebreaks

set guioptions-=T                            " remove toolbar in UI mode

set ignorecase                               " search is case insensitive, unless you use upper case characters
set smartcase

set scrolloff=2                              " start scrolling when you get close to the top or bottom

set textwidth=0                              " dont automatically insert linebreaks

set wildmenu                                 " show a menu in the status line when tab-completing commands

set history=500                              " longer history for : commands

set showbreak=↳\                             " nicer line wrapping, preserving indentation
set breakindent

set mousefocus                               " autofocus windows on hover

au FocusLost * silent! wa                    " save all buffers when vim loses focus

Tobias Kraze About 7 years ago