My minimal .vimrc

set nocompatible " disable Vi compatibility
set noswapfile autoread ttyfast visualbell " read file when changed, fast tty, visual bell
set switchbuf=useopen " use open buffer instead of duplicating
set autochdir " cd to dir of file in buffer
set hidden confirm " allow hiding unsaved buffers, confirm when deleting
set history=50 " command history
set mouse=a " enable mouse
set encoding=utf8
" fix scroll wheel
noremap <ScrollWheelUp> <C-Y>
noremap <ScrollWheelDown> <C-E>
" appearance
set background=dark t_Co=256
try " use solarized if it exists
  colorscheme solarized
  set cursorline
catch /^Vim\%((\a\+)\)\=:E185/
  colorscheme desert
set laststatus=2 " always show status line
set list number scrolloff=2 " visible white space, numbered lines and 2 lines above/below cursor
set listchars=tab:→\ ,trail:· " show tabs and trailing spaces
set wildchar=<tab> wildmenu wildmode=longest,list,full " auto complete menus
set wildcharm=<c-z> " like wildchar, but for use in macros
" status line
set statusline =%0*\[%n]                          " buffer no.
set statusline+=\ %<%F\                           " file path
set statusline+=\ %y\                             " file type
set statusline+=\ %{''.(&fenc!=''?&fenc:&enc).''} " encoding 1
set statusline+=\ %{(&bomb?\",BOM\":\"\")}\       " encoding 2
set statusline+=\ %{&ff}\                         " format
set statusline+=\ \[%{v:register}]\               " active reg
set statusline+=\ %=\ %l\ /\ %L\ (%3p%%)\         " line no. and pct
set statusline+=\ :%03v\                          " column no.
set statusline+=\ \ %m%r%w\ %P\ \                 " modified, ro, screen pos
" syntax highlight and indent
syntax on
filetype on
filetype plugin on
filetype indent on
set expandtab shiftwidth=2 softtabstop=2 tabstop=4 " default indent w/ 2 spaces
" writing
set textwidth=80
set formatoptions-=t " don't autowrap text
set formatoptions+=lcro " long lines, comment autowrap etc.
set whichwrap=b,s,<,>,[,]
set backspace=indent,eol,start " fix backspace
set cinoptions=l1 " fix c switch case block indentation
" searching
set ignorecase smartcase hlsearch incsearch " smart case, highlight, incremental
" gvim only
if has('gui_running')
  set guioptions=agiLt
  set lines=50 columns=120
  if has('gui_win32')
    set guifont=Consolas:h8:cANSI
    set guifont=consolas\ 9

" commands
let mapleader=" "
" remove highlights
nnoremap <leader><cr> :nohlsearch<cr>
" edit vimrc
nnoremap <leader>ev :edit $MYVIMRC<cr>
" source vimrc
nnoremap <leader>sv :source $MYVIMRC<cr>
" indent
vnoremap <tab> >gv
" unindent
vnoremap <s-tab> <gv
inoremap <s-tab> <c-o><<
" switch between buffers
noremap <f1> :bprev!<cr>
noremap <f2> :bnext!<cr>
nnoremap <leader>bb :b <c-z>
nnoremap <leader>bn :buffers<cr>:buffer<space>
nnoremap <leader>b! :buffers!<cr>:buffer<space>
nnoremap <leader><tab> :b!#<cr>
nnoremap <leader>bd :bdelete<cr>
" open files
nnoremap <leader>ff :Explore<cr>

" save as root
function! SudoW()
  write !sudo tee % >/dev/null
command! SudoW :call SudoW()

" a simple vimscript REPL that can be used as a calculator
function! Repl()
  while 1
    let expr = input("> ", "", "expression")
    if expr == "q" | break | endif
    if expr != ""
      echo "\n"
      if expr =~ "="
        execute "let " . expr
        let ans = eval(expr)
        echo string(ans)
nnoremap <leader>c :call Repl()<cr>

" optional packages installed using vim-plug
" install vim-plug and packages with :Install
  call plug#begin('~/.vim/plugged')

  Plug 'kien/ctrlp.vim', { 'on': 'CtrlP' }
  nnoremap <c-p> :CtrlP<cr>

  Plug 'vimwiki/vimwiki'
  let g:vimwiki_list = [{
    \ 'ext': '.md',
    \ 'syntax': 'markdown'
    \ }]

  call plug#end()
  function! Install()
    echom system("curl -fLo ~/.vim/autoload/plug.vim --create-dirs")
    source $MYVIMRC
  command! Install :call Install()