Skip to content

Instantly share code, notes, and snippets.

@krmnn
Created July 10, 2019 10:40
Show Gist options
  • Save krmnn/9035c6fa6e538ae37c293de2744954c1 to your computer and use it in GitHub Desktop.
Save krmnn/9035c6fa6e538ae37c293de2744954c1 to your computer and use it in GitHub Desktop.

Revisions

  1. krmnn created this gist Jul 10, 2019.
    824 changes: 824 additions & 0 deletions .vimrc
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,824 @@
    " .vimrc
    " 2009-2013 Thomas Karmann
    " Lots of cool stuff robbed from http://ruderich.org/simon/config/vimrc


    " set the runtime path to include Vundle and initialize
    set nocompatible
    filetype off
    set rtp+=~/.vim/bundle/Vundle.vim
    call vundle#begin()

    Plugin 'gmarik/Vundle.vim'
    Plugin 'pearofducks/ansible-vim'
    Bundle 'matze/vim-move'
    Bundle 'derekwyatt/vim-fswitch'
    Bundle 'scrooloose/nerdcommenter'
    Bundle 'scrooloose/nerdtree'
    Plugin 'Xuyuanp/nerdtree-git-plugin'
    Bundle 'ctrlpvim/ctrlp.vim'
    Bundle 'majutsushi/tagbar'
    Bundle 'ludovicchabant/vim-gutentags'
    Plugin 'guns/xterm-color-table.vim'
    Plugin 'adborden/vim-notmuch-address'
    Plugin 'nathangrigg/vim-beancount'

    call vundle#end() " required

    filetype plugin indent on " required
    syntax enable


    " Appearance
    colorscheme krmnn
    set background=dark

    " Display line numbers.
    set number
    " But use as little space as possible for the numbers column. Thanks to James
    " Vega (http://git.jamessan.com/?p=etc/vim.git;a=summary).
    if exists('+numberwidth')
    set numberwidth=1
    endif
    " Display the ruler with current line/file position. If 'statusline' is used
    " then this only affects <C-G>.
    set ruler
    " Display partial commands in the status line.


    " Don't redraw screen when executing macros; increases speed. Thanks to James
    " Vega (http://git.jamessan.com/?p=etc/vim.git;a=summary).
    set lazyredraw

    " Visualize the line the cursor is currently in.
    if exists('+cursorline')
    set cursorline
    endif

    " Highlight all matches on the screen when searching. Use <C-L> (see below) to
    " remove the highlighting until the next search.
    set hlsearch


    " Display some special characters.
    "set list
    set listchars=
    " Display tabs as ">--------".
    set listchars+=tab:>-
    " Display trailing whitespace as "-".
    set listchars+=trail:-
    " Display markers for long lines when wrapping is disabled.
    set listchars+=extends:>,precedes:<
    " Display non-breakable space as "!".
    if v:version >= 700
    set listchars+=nbsp:!
    endif

    " Don't draw the vertical split separator by using space as character. Thanks
    " to scp1 in #vim on Freenode (2012-06-16 16:12 CEST) for the idea to use a
    " non-breakable space. But a simple space works as well, as long as the
    " current color scheme is not reset.
    if has('windows') && has('folding')
    set fillchars+=vert:\ " comment to prevent trailing whitespace
    endif

    if has('statusline')
    " Always display the status line even if there is only one window.
    set laststatus=2

    " If there's more than one buffer return "/<nr>" (e.g. "/05") where <nr>
    " is the highest buffer number, otherwise return nothing. Used in
    " 'statusline' to get an overview of available buffer numbers.
    function! s:StatuslineBufferCount()
    let l:bufnr = bufnr('$')
    if l:bufnr > 1
    let l:result = '/'
    if exists('*printf')
    let l:result .= printf('%02d', l:bufnr)
    else
    " Older Vims don't have printf() (and no .= either). Emulate
    " "%02d".
    if l:bufnr < 10
    let l:result = l:result . '0'
    endif
    let l:result = l:result . l:bufnr
    endif
    return l:result
    else
    return ''
    endif
    endfunction

    " Like %f but use relative filename if it's shorter than the absolute path
    " (e.g. '../../file' vs. '~/long/path/to/file'). fnamemodify()'s ':.' is
    " not enough because it doesn't create '../'s.
    function! s:StatuslineRelativeFilename()
    " Display only filename for help files.
    if &buftype == 'help'
    return expand('%:t')
    endif
    " Special case for scratch files.
    if &buftype == 'nofile'
    return '[Scratch]'
    endif

    let l:path = expand('%')
    " No file.
    if l:path == ''
    return '[No Name]'
    endif
    " Path is already relative, nothing to do.
    if stridx(l:path, '/') != 0
    return l:path
    endif

    " Absolute path to this file.
    let l:path = expand('%:p')
    " Shortened path to this file, thanks to bairui in #vim on Freenode
    " (2012-06-23 00:54) for the tip to use fnamemodify(). This is what
    " Vim normally uses as %f (minus some exceptions).
    let l:original_path = fnamemodify(l:path, ':~')
    " Absolute path to the current working directory.
    let l:cwd = getcwd()

    " Working directory completely contained in path, replace it with a
    " relative path. Happens for example when opening a file with netrw.
    " %f displays this as absolute path, but we want a relative path of
    " course.
    if stridx(l:path, l:cwd) == 0
    return strpart(l:path, strlen(l:cwd) + 1)
    endif

    let l:path_list = split(l:path, '/')
    let l:cwd_list = split(l:cwd, '/')

    " Remove the common path.
    while l:path_list[0] == l:cwd_list[0]
    call remove(l:path_list, 0)
    call remove(l:cwd_list, 0)
    endwhile

    " Add as many '..' as necessary for the relative path and join the
    " path. Thanks to Raimondi in #vim on Freenode (2012-06-23 01:13) for
    " the hint to use repeat() instead of a loop.
    let l:path = repeat('../', len(l:cwd_list)) . join(l:path_list, '/')

    " Use the shorter path, either relative or absolute.
    if strlen(l:path) < strlen(l:original_path)
    return l:path
    else
    return l:original_path
    endif
    endfunction

    " Display unexpected 'fileformat', 'fileencoding' and 'bomb' settings.
    function! s:StatuslineFileFormat()
    if &fileformat != 'unix'
    return '[' . &fileformat . ']'
    else
    return ''
    endif
    endfunction
    function! s:StatuslineFileEncoding()
    if &fileencoding != '' && &fileencoding != 'utf-8'
    \ && &filetype != 'help'
    return '[' . &fileencoding . ']'
    else
    return ''
    endif
    endfunction
    function! s:StatuslineFileBOMB()
    if exists('+bomb') && &bomb
    return '[BOM]'
    else
    return ''
    endif
    endfunction

    " Return current syntax group in brackets or nothing if there's none.
    function! s:StatuslineSyntaxGroup()
    let l:group = synIDattr(synID(line('.'), col('.'), 1), 'name')
    if l:group != ''
    return '[' . l:group . '] '
    else
    return ''
    endif
    endfunction

    " Short function names to make 'statusline' more readable.
    function! SBC()
    return s:StatuslineBufferCount()
    endfunction
    function! SRF()
    return s:StatuslineRelativeFilename()
    endfunction
    function! SFF()
    return s:StatuslineFileFormat()
    endfunction
    function! SFE()
    return s:StatuslineFileEncoding()
    endfunction
    function! SFB()
    return s:StatuslineFileBOMB()
    endfunction
    function! SSG()
    return s:StatuslineSyntaxGroup()
    endfunction

    set statusline=
    " on the left
    set statusline+=%02n " buffer number
    set statusline+=%{SBC()} " highest buffer number
    set statusline+=:
    if has('modify_fname') && v:version >= 700 " some functions need 7.0
    set statusline+=%{SRF()} " path to current file
    set statusline+=\ " space after path
    else
    set statusline+=%f\ " path to current file in buffer
    endif
    set statusline+=%h " [help] if buffer is help file
    set statusline+=%w " [Preview] if buffer is preview buffer
    set statusline+=%m " [+] if buffer was modified,
    " [-] if 'modifiable' is off
    set statusline+=%r " [RO] if buffer is read only
    if v:version >= 700 " %#..# needs 7.0
    set statusline+=%#Error# " display warnings
    set statusline+=%{SFF()} " - unexpected file format
    set statusline+=%{SFE()} " - unexpected file encoding
    set statusline+=%{SFB()} " - unexpected file byte order mask
    set statusline+=%## " continue with normal colors
    endif

    " on the right
    set statusline+=%= " right align
    set statusline+=0x%-8B\ " current character under cursor as hex
    set statusline+=%{gutentags#statusline()}
    set statusline+=%-12.(%l,%c%V%)\ " line number (%l),
    " column number (%c),
    " virtual column number if different
    " than %c (%V)
    set statusline+=%P " position in file in percent
    endif

    set display=lastline
    set showfulltag


    " first, enable status line always
    set laststatus=2

    " now set it up to change the status line based on mode
    if version >= 700
    au InsertEnter * hi StatusLine cterm=none ctermfg=black ctermbg=green
    au InsertLeave * hi StatusLine cterm=none ctermfg=white ctermbg=black
    endif


    " Behaviour
    set cinoptions+=t0
    " enables forward delete including newlines
    set backspace=2
    set complete+=k
    set shell=/bin/bash
    set mouse-=a

    " Use UTF-8 for all internal data (buffers, registers, etc.). This doesn't
    " affect reading files in different encodings, see 'fileencodings' for that.
    set encoding=utf-8

    " Don't store swap files in the same directory as the edited file, but only if
    " we have a "safe" writable directory available.
    if filewritable('~/.tmp') == 2 || filewritable('~/tmp') == 2
    set directory-=.
    else
    " But store them in ~/.tmp or ~/tmp (already set by default) if available.
    set directory^=~/.tmp
    endif


    " Make sure Vim (and not Vi) settings are used.

    set autoread


    " Disable modelines as they may cause security problems. Instead use
    " securemodelines (Vim script #1876).
    set nomodeline


    " Complete to longest common string (list:longest) and then complete all full
    " matches after another (full). Thanks to pbrisbin
    " (http://pbrisbin.com:8080/dotfiles/vimrc).
    set wildmode=list:longest,full
    " Ignore case when completing files/directories.
    if exists('+wildignorecase')
    set wildignorecase
    endif

    " Show completion menu even if only one entry matches.
    if exists('+completeopt')
    set completeopt+=menuone
    endif

    " Increase history of executed commands (:) and search patterns (/).
    set history=1000

    " Increase number of possible undos.
    set undolevels=1000


    " Remember marks (including the last cursor position) for more files. ^= is
    " necessary because 'viminfo' is parsed from the beginning and the first match
    " is used.
    if has('viminfo')
    set viminfo^='1000
    endif

    " Use strong encryption if possible, also used for swap/undo files.
    if exists('+cryptmethod')
    set cryptmethod=blowfish
    endif



    " HELPER FUNCTIONS

    if has('eval')
    " Check if the given syntax group is available. Thanks to bairui in #vim on
    " Freenode (2012-02-19 01:15 CET) for the try/catch silent highlight idea.
    function! s:HasSyntaxGroup(group)
    try
    execute 'silent highlight ' . a:group
    " \a = [A-Za-z]
    catch /^Vim\%((\a\+)\)\=:E411/ " 'highlight group not found'
    return 0
    endtry
    return 1
    endfunction

    " Check if the given Vim version and patch is available.
    function! s:HasVersionAndPatch(version, patch)
    return v:version > a:version
    \ || (v:version == a:version && has('patch' . a:patch))
    endfunction
    endif


    set showmatch

    set ignorecase
    set smartcase

    set ruler
    set t_Co=256

    set showcmd " show command in the last line

    set scrolloff=1 " keep one line above and below current scroll position
    set sidescrolloff=5 " keep 5 columns to the left and right

    source ~/.vim/macros.vim

    " Tip #370: always cd to the current file's directory
    autocmd BufEnter * if bufname("") !~ "^\[A-Za-z0-9\]*://" | lcd %:p:h | endif

    " search
    set hlsearch " highlight search terms
    set incsearch " incremental searching
    set ignorecase " searches are case insensitive ...
    set smartcase " ... unless they contain at least one capital letter

    " files
    "set directory=~/.vim/files/swap " don't save swap files to .

    " menu and completion
    set wildmenu
    set wildmode=longest:full

    " Copy and Paste
    set pastetoggle=<F2>

    " Bind nohl
    " Removes highlight of your last search
    "noremap <C-n> :nohl<CR>
    "vnoremap <C-n> :nohl<CR>
    "inoremap <C-n> :nohl<CR>

    " Search
    set hlsearch
    set incsearch
    set infercase

    " EDIT SETTINGS

    " Use UTF-8 file encoding for all files. Automatically recognize latin1 in
    " existing files.
    set fileencodings=utf-8,latin1

    " Always use unix line-endings for new files.
    set fileformats=unix,dos

    " Set tabs to 4 spaces, use softtabs.
    set shiftwidth=4
    set softtabstop=4
    set expandtab
    " When < and > is used indent/deindent to the next 'shiftwidth' boundary.
    set shiftround
    " Use the default value for real tabs.
    set tabstop=8

    " Enable auto indention.
    set autoindent


    " When joining lines only add one space after a sentence.
    set nojoinspaces

    " Allow backspacing over autoindent and line breaks.
    "set backspace=indent,eol

    " Start a comment when hitting enter after a commented line (r) and when using
    " o or O around a commented line (o).
    set formatoptions+=ro
    " Don't break a line if was already longer then 'textwidth' when insert mode
    " started.
    set formatoptions+=l
    " Remove comment leader when joining lines where it makes sense.
    if s:HasVersionAndPatch(703, 541)
    set formatoptions+=j
    endif


    " Allow virtual editing (cursor can be positioned anywhere, even when there is
    " no character) in visual block mode.
    set virtualedit=block

    " Already display matches while typing the search command. This makes spotting
    " typos easy and searching faster.
    set incsearch

    "" Activate syntax folding.
    if has('folding')

    set foldmethod=syntax

    " Only use fold column if we have enough space (for example not in a
    " (virtual) terminal which has only 80 columns).
    "if &columns > 80
    "set foldcolumn=2
    "endif

    set foldlevel=99 " no closed folds at default, 'foldenable' would disable
    " folding which is not what I want
    " Don't open folds for block movements like '(', '{', '[[', '[{', etc.
    set foldopen-=block

    " Enable folding with the spacebar
    nnoremap <space> za
    endif

    " Only check case if the searched word contains a capital character.
    set ignorecase
    set smartcase

    " Activate spell checking, use English as default.
    if exists('+spell') && has('syntax')
    " But not when diffing because spell checking is distracting in this case.
    if !&diff
    set spell
    endif
    "set spelllang=de_DE
    "set dictionary+=/usr/share/words
    "autocmd FileType mail :nmap <F8> :w<CR>:!aspell -e -c %<CR>:e<CR>
    set spelllang=en_us
    endif



    " Programming
    " c, c++, c#, java, objc
    set cinoptions+=t0
    autocmd Filetype c,cpp,cs,java,objc set cindent
    autocmd Filetype c,cpp,cs,java,objc set cst csto=0
    " C
    au BufRead,BufNewFile *.c,*.h set expandtab
    au BufRead,BufNewFile *.c,*.h set tabstop=4
    au BufRead,BufNewFile *.c,*.h set shiftwidth=4
    au BufRead,BufNewFile *.c,*.h set autoindent
    au BufRead,BufNewFile *.c,*.h match BadWhitespace /^\t\+/
    au BufRead,BufNewFile *.c,*.h match BadWhitespace /\s\+$/
    au BufNewFile *.c,*.h set fileformat=unix
    au BufRead,BufNewFile *.c,*.h let b:comment_leader = '/* '

    " python
    " Python, PEP-008
    au BufRead,BufNewFile *.py,*.pyw set expandtab
    au BufRead,BufNewFile *.py,*.pyw set textwidth=139
    au BufRead,BufNewFile *.py,*.pyw set tabstop=4
    au BufRead,BufNewFile *.py,*.pyw set softtabstop=4
    au BufRead,BufNewFile *.py,*.pyw set shiftwidth=4
    au BufRead,BufNewFile *.py,*.pyw set autoindent
    au BufRead,BufNewFile *.py,*.pyw match BadWhitespace /^\t\+/
    au BufRead,BufNewFile *.py,*.pyw match BadWhitespace /\s\+$/
    au BufNewFile *.py,*.pyw set fileformat=unix
    au BufRead,BufNewFile *.py,*.pyw let b:comment_leader = '#'

    autocmd Filetype python set makeprg=pychecker
    autocmd Filetype python map <F5> :!python % <CR>
    autocmd Filetype python map <F7> :make % <CR>
    autocmd Filetype python set tabstop=4
    autocmd Filetype python set shiftwidth=4

    " Multi-windowing. CTRL+[HJKL] to switch windows and maximize
    map <C-S> <C-W>s
    map <C-D> <C-W>v
    map <C-J> <C-W>j
    map <C-K> <C-W>k
    map <C-H> <C-W>h
    map <C-L> <C-W>l
    " Ctrl-B is 'build'
    imap <C-b> <Esc>:w<CR>:silent! make \| redraw!<CR>:cw<CR>
    nmap <C-b> :w<CR>:silent! make \| redraw!<CR>:cw<CR>
    vmap <C-b> :w<CR>:silent! make \| redraw!<CR>:cw<CR>
    " This beauty remembers where you were the last time you edited the file, and returns to the same position.
    au BufReadPost * if line("'\"") > 0|if line("'\"") <= line("$")|exe("norm '\"")|else|exe "norm $"|endif|endif

    "execute pathogen#infect()

    syntax on


    "let mapleader = ""

    " minibufexplorer
    let g:miniBufExplMapWindowNavVim = 1
    let g:miniBufExplMapWindowNavArrows = 1
    let g:miniBufExplMapCTabSwitchBufs = 1
    let g:miniBufExplModSelTarget = 1

    " window navigation
    map <c-l> <c-w>l
    map <c-j> <c-w>j
    map <c-k> <c-w>k
    map <c-h> <c-w>h
    "map <C-S-l> <c-w><s-l>
    "map <C-S-j> <c-w><s-j>
    "map <C-S-k> <c-w><s-k>
    "map <C-S-h> <c-w><s-h>



    " Python mode plugin
    map <Leader>g :call RopeGotoDefinition()<CR>
    let ropevim_enable_shortcuts = 1
    let g:pymode_rope_goto_def_newwin = "vnew"
    let g:pymode_rope_extended_complete = 1
    let g:pymode_breakpoint = 0
    let g:pymode_syntax = 1
    let g:pymode_syntax_builtin_objs = 0
    let g:pymode_syntax_builtin_funcs = 0
    map <Leader>b Oimport ipdb; ipdb.set_trace() # BREAKPOINT<C-c>
    "tab complete
    function! InsertTabWrapper(direction)
    let col = col('.') - 1
    if !col || getline('.')[col - 1] !~ '\k'
    return "\<tab>"
    elseif "backward" == a:direction
    return "\<c-p>"
    else
    return "\<c-n>"
    endif
    endfunction
    inoremap <tab> <c-r>=InsertTabWrapper ("forward")<cr>
    "inoremap <s-tab> <c-r>=InsertTabWrapper ("backward")<cr>

    " Mappings
    nmap <C-i> :TagbarToggle<CR>
    " Make last active window the only window. Similar to <C-W> o.
    nnoremap <C-W>O <C-W>p<C-W>o
    set nospell
    " Maps to change spell language between English and German and disable spell
    " checking.
    if exists('+spell')
    nnoremap <silent> <Leader>sn :set nospell<CR>
    nnoremap <silent> <Leader>se :set spell spelllang=en_us<CR>
    nnoremap <silent> <Leader>sd :set spell spelllang=de_de<CR>
    " If no spell support is available, these mappings do nothing.
    else
    nmap <Leader>sn <Nop>
    nmap <Leader>se <Nop>
    nmap <Leader>sd <Nop>
    endif




    " SYNTAX SETTINGS

    " Activate syntax coloring.
    if has('syntax')
    syntax enable

    " Don't highlight more than 500 columns as I normally don't have that long
    " lines and they slow down syntax coloring. Thanks to Derek Wyatt
    " (http://www.derekwyatt.org/vim/the-vimrc-file/).
    if exists('+synmaxcol')
    set synmaxcol=500
    endif

    " Use (limited) syntax based omni completion if no other omni completion is
    " available. Taken from :help ft-syntax-omni.
    if has('autocmd') && exists('+omnifunc')
    augroup vimrc
    autocmd FileType *
    \ if &omnifunc == '' |
    \ setlocal omnifunc=syntaxcomplete#Complete |
    \ endif
    augroup END
    endif

    " Function to enable all custom highlights. Necessary as highlights are
    " window-local and thus must be set for each new window.
    function! s:CustomSyntaxHighlights()
    " Not the first time called, nothing to do.
    if exists('w:vimrc_syntax_run')
    return
    endif
    let w:vimrc_syntax_run = 1

    " Highlight lines longer than 78 characters. Thanks to Tony Mechelynck
    " <[email protected]> from the Vim mailing list. It can easily be
    " disabled when necessary with :2match (in Vim >= 700).
    " if !&diff && exists(':2match')
    " 2match Todo /\%>78v./
    " elseif !&diff
    " match Todo /\%>78v./
    " endif

    if exists('*matchadd')
    " Highlight some important keywords in all documents.
    let l:todos = ['TODO', 'XXX', 'FIXME',
    \ 'CHANGED', 'REMOVED', 'DELETED']
    " Compatibility fix for Vim 6.4 which can't handle for in function
    " (without function it's ignored).
    execute ' for l:x in l:todos'
    \ '| call matchadd("Todo", l:x)'
    \ '| endfor'

    " Highlight Unicode whitespace which is no normal whitespace (0x20).
    let l:spaces = ['00a0', '1680', '180e', '2000', '2001', '2002',
    \ '2003', '2004', '2005', '2006', '2007', '2008',
    \ '2009', '200a', '200b', '200c', '200d', '202f',
    \ '205f', '2060', '3000', 'feff']
    " Compatibility fix for Vim 6.4. Escape \ inside the " string or
    " it won't work!
    execute ' for l:x in l:spaces'
    \ '| call matchadd("Error", "\\%u" . l:x)'
    \ '| endfor'
    endif
    endfunction
    " Enable highlights for the current and all new windows. Thanks to bairui in
    " #vim on Freenode (2012-04-01 00:22 CEST) for the WinEnter suggestion.
    call s:CustomSyntaxHighlights()
    if has('autocmd')
    augroup vimrc
    autocmd WinEnter * call s:CustomSyntaxHighlights()
    augroup END
    endif



    " Settings for specific filetypes.

    " C
    let g:c_no_if0_fold = 1 " fix weird double fold in #if0 in recent versions

    " Haskell.
    let g:hs_highlight_delimiters = 1
    let g:hs_highlight_boolean = 1
    let g:hs_highlight_types = 1
    let g:hs_highlight_more_types = 1

    " Java.
    let g:java_highlight_java_lang_ids = 1 " color java.lang.* identifiers
    " Perl.
    let g:perl_fold = 1
    let g:perl_fold_blocks = 1
    let g:perl_nofold_packages = 1
    let g:perl_include_pod = 1 " syntax coloring for PODs
    " PHP.
    let g:php_folding = 3 " fold functions
    let g:php_short_tags = 0 " no short tags (<? .. ?>), not always usable
    let g:php_sql_query = 1 " highlight SQL queries in strings

    " Python.
    let g:python_highlight_all = 1
    " Shell.
    let g:sh_noisk = 1 " don't add . to 'iskeyword'
    let g:sh_is_posix = 1 " POSIX shell (e.g. dash) is compatible enough
    let g:sh_fold_enabled = 7 " functions (1), heredoc (2) and if/do/for (4)
    " Vim.
    let g:vimsyn_embed = 0 " don't highlight embedded languages
    let g:vimsyn_folding = 'af' " folding for autogroups (a) and functions (f)
    " XML.
    let g:xml_syntax_folding = 1
    endif

    " auto commands
    " Fix to allow Vim edit crontab files as crontab doesn't work with
    " backupcopy=auto.
    autocmd FileType crontab setlocal backupcopy=yes

    " PLUGIN SETTINGS

    if has('eval')
    " Use pathogen which allows one 'runtimepath' entry per plugin. This makes
    " installing/removing/updating plugins simple. (Used for plugins with more
    " than one file.) Ignore errors in case pathogen is not installed.
    "if v:version >= 700
    "silent! execute 'call pathogen#infect()'
    "endif

    " Settings for securemodelines.
    " Only allow items I need (also includes spl which is not enabled by
    " default).
    if v:version >= 700 " need lists
    let g:secure_modelines_allowed_items = ['ft', 'spl', 'fdm',
    \ 'sw', 'sts', 'noet']
    endif

    " Settings for the NERD commenter.
    " Don't create any mappings I don't want to use.
    let g:NERDCreateDefaultMappings = 0
    " Map toggle comment.
    nmap <C-c> <Plug>NERDCommenterToggle
    vmap <C-c> <Plug>NERDCommenterToggle
    " Settings for the NERD tree.
    autocmd StdinReadPre * let s:std_in=1
    autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
    autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif

    autocmd StdinReadPre * let s:std_in=1
    autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | exe 'cd '.argv()[0] | endif

    map <C-n> :NERDTreeToggle<CR>
    " XPTemplate settings.
    " Try to maintain snippet rendering even after editing outside of a
    " snippet.
    let g:xptemplate_strict = 0
    " Don't complete any braces automatically.
    let g:xptemplate_brace_complete = 0
    " Only highlight the current placeholder.
    let g:xptemplate_highlight = 'current'

    " CtrlP settings.
    " Don't manage the working directory (the default setting is too slow for
    " me).
    let g:ctrlp_working_path_mode = 0

    " Path to cache directory. I prefer to keep generated files as local as
    " possible.
    let g:ctrlp_cache_dir = $HOME . '/.cache/ctrlp'
    " Permanent cache, cleared by a crontab entry. Use <F5> to update the
    " cache manually.
    let g:ctrlp_clear_cache_on_exit = 0

    " Don't switch the window if the selected buffer is already open. I want
    " to open another view on this buffer in most cases.
    let g:ctrlp_switch_buffer = 0

    nnoremap <c-f> :CtrlPTag<cr>

    " FSWitch settings.
    " Defaults don't work well for my projects.
    augroup vimrc
    autocmd BufEnter *.cc let b:fswitchdst = 'h'
    \ | let b:fswitchlocs = './'
    autocmd BufEnter *.h let b:fswitchdst = 'cc,c'
    \ | let b:fswitchlocs = './'
    augroup END

    " Switch to corresponding header/source file.
    nnoremap <silent> <Leader>h :FSHere<CR>
    " netrw settings.
    " Don't create ~/.vim/.netrwhist history file.
    let g:netrw_dirhistmax = 0
    endif

    " vim-move plugin: use ctrl
    let g:move_key_modifier = 'S'

    let g:gutentags_cache_dir = '~/.cache/gutentags'
    " let g:gutentags_ctags_executable = 'ctags-universal'