by June 26, 2013on
To my mind vim is probably the best editor for programming and text editing. However there are various helpful settings that are not set by most distribution’s default installations you may want to know to get the most out of your vim editing experience. Moreover there are a bunch of vim scripts that should not miss in your vim runtime files.
The following settings are not meant to be a fully functional or useful vim configuration but more of a collection of snippets you could consider adding to your own
.vimrc. In my opinion you should not blindly copy other people’s vim configuration files without understanding every single setting itself anyway.
However you can find a copy of my
.vimrc on github for reference or inspiration.
The most important non-default setting is called
hidden which enables you to switch between buffers without having to save in between. This is very important in order to understand vim’s concept of buffers and tabs which may appear somewhat different compared to other popular text editors. See
:h buffers and
:h tabpage for further information.
" disable VI compatibility set nocompatible " enable buffer switching without having to save set hidden " allow backspace in insert mode set backspace=indent,eol,start " always activate automatic indentation set autoindent
" display statusline even if there is only one window set laststatus=2 " visually break lines set wrap " display line numbers set number " line numbers as narrow as possible set numberwidth=1
" turn on highlight search set hlsearch " ignore case in search when no uppercase search set incsearch set ignorecase set smartcase
Starting from a basic set of options you can incrementally improve or extend your vim configuration by exploring vim’s options. For one you can get help for every setting by invoking
:h :<optionname>. Moreover you can get a complete list of available options via
Find a few very basic key mappings you may find useful as well:
" redraw screen and remove search highlights nnoremap <silent> <C-l> :noh<CR><C-l> " yank to end of line nnoremap Y y$ " use Q for formatting noremap Q gq " easier navigation on wrapped lines nnoremap j gj nnoremap k gk
You may find a few of my favourite plugins below:
pathogen: This plugin by Tim Pope is the undisputed must-have plugin for managing your vim runtime path and therefore your plugins. With pathogen you then can easily manage your plugins i.e. using git submodules.
syntastic: Live syntax checking at its best - I am fully objective here although I am contributing to this amazing plugin :-)
Command-T: Fast and intuitive file searching plugin written by Wincent Colaiuta (requires ruby enabled vim)
Just to name a few other great plugins you may want to check out: FSwitch, Tagbar, NerdCommenter, NerdTree …