1 " Purpose: My personal .vimrc
4 "profile start /tmp/profile.log
10 set backspace=indent,eol,start
15 set grepprg=grep\ -nH\ $*
25 set listchars=tab:»,trail:·,eol:$
34 set spelllang=de_at,en
39 set wildmode=longest,list:longest
44 filetype plugin indent on
46 runtime! autoload/plug.vim
47 " Check if there is vim-plug installed
48 if exists('g:loaded_plug')
49 call plug#begin('~/.config/nvim/plugged')
50 Plug 'Glench/Vim-Jinja2-Syntax'
51 Plug 'LaTeX-Box-Team/LaTeX-Box'
52 Plug 'benekastah/neomake'
53 Plug 'vim-airline/vim-airline'
54 Plug 'vim-airline/vim-airline-themes'
55 Plug 'chrisbra/csv.vim'
56 Plug 'craigemery/vim-autotag'
57 Plug 'derekwyatt/vim-fswitch'
58 Plug 'godlygeek/tabular'
59 "Plug 'kien/ctrlp.vim'
61 Plug 'majutsushi/tagbar'
62 Plug 'mhinz/vim-signify'
63 Plug 'msanders/snipmate.vim'
64 Plug 'scrooloose/nerdcommenter'
65 Plug 'scrooloose/nerdtree'
66 " Plug 'scrooloose/syntastic'
68 Plug 'Shougo/deoplete.nvim'
69 Plug 'suan/vim-instant-markdown'
70 Plug 'StanAngeloff/php.vim'
72 Plug 'thinca/vim-fontzoom'
73 Plug 'tpope/vim-ragtag'
74 Plug 'vim-scripts/CSApprox'
75 Plug 'vim-scripts/DetectIndent'
76 Plug 'vim-scripts/git_patch_tags.vim'
77 Plug 'vim-scripts/loremipsum'
80 autocmd! BufWritePost,BufEnter * Neomake
82 " If there is no vim-plug, try pathogen
84 runtime autoload/pathogen.vim
85 if exists("g:loaded_pathogen")
86 " Pathogen runtime path manipulation
87 call pathogen#runtime_append_all_bundles()
88 call pathogen#helptags()
94 set rtp^=/usr/share/vim/vimfiles
103 let $NVIM_TUI_ENABLE_TRUE_COLOR=1
105 let g:CSApprox_attr_map = { 'bold' : 'bold', 'italic' : 'underline', 'sp' : 'bg' }
107 colorscheme shuber-wombat
110 " Use the below highlight group when displaying bad whitespace is desired.
111 highlight BadWhitespace ctermbg=red guibg=red
112 " Make trailing whitespace be flagged as bad.
113 au Filetype python,tex,c,cpp,cs,objc,java,vim syn match BadWhitespace /\s\+$/ containedin=ALL
114 au Filetype python,tex,c,cpp,cs,objc,java,vim let g:airline#extensions#whitespace#enabled = 0
117 " Detect indentation, but otherwise set expandtab
118 if exists(":DetectIndent")
119 au BufReadPost * :DetectIndent
123 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
125 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
127 let g:airline_powerline_fonts = 0
128 let g:airline_theme = 'wombat'
130 let g:airline#extensions#tabline#enabled = 1
131 let g:airline#extensions#tagbar#enabled = 0
132 let g:airline#extensions#whitespace#enabled = 0
133 let g:airline#extensions#branch#enabled = 1
134 let g:airline#extensions#branch#use_vcscommand = 1
136 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
138 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
140 "Open current file with a specific program
141 function OpenIn(prog)
142 execute ":!" . a:prog . " % &"
146 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
148 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
150 nmap <s-PageDown> :bn<CR>
151 nmap <s-PageUp> :bp<CR>
153 map <a-c> <plug>NERDCommenterToggle
154 nmap <F10> :TagbarToggle<CR>
158 "vmap <c-s> <Esc><c-s>gv
159 "imap <c-s> <c-o><c-s>
163 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
165 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
166 nmap <F9> :NERDTreeToggle<CR>
167 let g:NERDTreeDirArrows = 1
168 let g:NERDTreeDirArrowExpandable = '▸'
169 let g:NERDTreeDirArrowCollapsible = '▾'
172 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
174 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
176 "let fortran_free_source=1
177 au BufNewFile *.f90 set fortran_free_source=1
178 au Filetype fortran set cindent cst csto=0
181 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
182 " C, C++, C#, objc, java
183 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
185 au Filetype c,cpp,cs,objc,java set cindent cst csto=0
187 au Filetype c,cpp,cs,objc,java map <buffer> <F4> :cnext<CR>
188 au Filetype c,cpp,cs,objc,java map <buffer> <S-F4> :cprevious<CR>
190 au Filetype c,cpp,cs,objc set makeprg=make
191 au Filetype c,cpp,cs,objc map <buffer> <F7> :make<CR>
192 au Filetype java map <buffer> <F7> :!ant -f ../build.xml<CR>
195 runtime! plugin/fswitch.vim
197 au Filetype c,cpp,objc map <buffer> <F11> :vsplit<CR>:FSRight<CR>
198 au Filetype c,cpp,objc map <buffer> <S-F11> :FSHere<CR>
200 " Substitute lib <-> include, otherwise take the same directory
201 au BufEnter *.c* let b:fswitchlocs='reg:/lib/include/,rel:.'
202 au BufEnter *.h* let b:fswitchlocs='reg:/include/lib/,rel:.'
203 "au BufEnter *.c* let b:fswitchlocs='rel:.,rel:../inc*/**,rel:../../inc*/**'
205 au BufEnter *.cpp,*.cc,*.cxx let b:fswitchdst='h,hxx,hpp,hh'
206 au BufEnter *.h,*.hh,*.hxx let b:fswitchdst='cc,c,cxx,cpp'
208 au Filetype c,cpp,cs,objc,java map <buffer> <F11> :AS<CR>
209 au Filetype c,cpp,cs,objc,java map <buffer> <S-F11> :A<CR>
213 "Prepend the namespace to an identifier, e.g. 'std::' before 'map' excluding
214 "those in C/C++ comments.
215 function PrependCppNamespaceToIdent(ns, id)
217 " To match Not to match
221 "|/* */ /* */ id |/* */ // id
229 " In order to not match '* id' it is assumed that multi-line comment lines
230 " in the middle begin with a star.
232 " If #include and // and /* and ^* and :: is not prepend:
233 execute ':%s@\(\(#include\|\/\/\|\/\*\|^\s*\*[^/]\).*\|::\)\@<!\<' . a:id . '\>@' . a:ns . '::' . a:id . '@ge'
234 " If #include and // and :: is not prepend, but */ is, and no further /* or // are found
235 execute ':%s@\(\(#include\|\/\/\).*\)\@<!\*\/\(\/[^\/\*]\|[^\/]\)*\zs\(::\)\@<!\<' . a:id . '\>@' . a:ns . '::' . a:id . '@ge'
239 "Prepend STL namespace 'std::' to several identifiers
240 function PrependSTLNamespace()
241 " This list of identifier is not complete, but adding all of them is too
242 " much. We rather like to add identifieres that are 'typical' for C++.
243 " Others, like 'move' are likely to not be C++ specific. In this cases the
244 " user is asked to call PrependCppNamespaceToIdent by hand.
246 let id = id +['cin', 'cout', 'cerr', 'endl']
247 let id = id +['swap', 'sort', 'max', 'min']
248 let id = id +['vector', 'deque', 'list', 'map', 'multimap', 'set']
249 let id = id +['queue', 'stack', 'priority_queue']
250 let id = id +['ostream', 'istream', 'sstream']
251 let id = id +['pair', 'string']
254 call PrependCppNamespaceToIdent("std", i)
258 function EscapeHexToChar()
259 echo 'Call "x/Nxb addr" in GDB to print N bytes at addr'
261 execute '%s/\s*0x\(\x\x\)/\\x\1/g'
262 execute '%s/^\(.*\)$/"\1"/'
265 function InsertIncludeGuardsWithoutEndif()
266 let gatename = substitute(expand("%:t"), "\\.", "_", "g") . '_' . strpart(system('pwgen -c 16 1'), 0, 16)
267 execute "normal! i#ifndef " . gatename
268 execute "normal! o#define " . gatename
271 function AddIncludeGuards()
272 execute "normal! Go#endif"
274 call InsertIncludeGuardsWithoutEndif()
277 autocmd BufNewFile *.{h,hpp,hxx} call AddIncludeGuards()
280 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
282 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
284 au Filetype text set textwidth=80
285 au Filetype markddown set textwidth=80
286 "According to thunderbirds settings
287 au Filetype mail set textwidth=72
288 au Filetype mail set expandtab
290 "a and w reformat the paragraph automatically and a new paragraph
291 "is indicated by lines not ending with white-space
293 au Filetype mail,text set fo+=n spell
297 au Filetype mail syn match Statement /^\s*-*\s*>8\s*-*\s*$/
298 au Filetype mail syn match Statement /^\s*-*\s*8<\s*-*\s*$/
301 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
303 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
305 "au Filetype php set fo=tcqn
307 au Filetype php set spell
310 au Filetype php set textwidth=80
311 "au Filetype php set cindent
314 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
316 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
318 au BufRead,BufNewFile *.wxm set filetype=maxima
321 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
323 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
325 let g:LatexBox_split_side = "rightbelow"
326 "let g:LatexBox_split_resize = 1
327 let g:LatexBox_ref_pattern = '\c\\\a*ref\*\?\_\s*{'
329 let g:tex_flavor = "latex"
330 let g:LatexBox_output_type = "pdf"
331 let g:LatexBox_viewer = "okular"
332 let g:LatexBox_latexmk_async = 1
333 let g:LatexBox_latexmk_preview_continuously = 1
334 "let g:LatexBox_show_warnings = 0
335 let g:LatexBox_quickfix = 4
338 au Filetype tex set spell
341 au BufRead,BufNewFile *.cls set filetype=tex
342 au Filetype tex set textwidth=80
343 au Filetype tex set shiftwidth=2
344 au Filetype tex set smartindent
345 " Override Tagbar Toggle with LatexBox TOC
346 au Filetype tex nmap <buffer> <F10> :LatexTOCToggle<CR>
347 au Filetype tex nmap <buffer> <F11> :LatexLabels<CR>
351 function TexTransUmlaute()
352 execute ':%s/ü/\\\"u/ge'
353 execute ':%s/Ü/\\\"U/&'
354 execute ':%s/ö/\\\"o/&'
355 execute ':%s/Ö/\\\"O/&'
356 execute ':%s/ä/\\\"a/&'
357 execute ':%s/Ä/\\\"A/&'
358 execute ':%s/ß/\\\"s/&'
359 execute ':%s/²/\^2/&'
362 function FindWordRepeatings()
363 execute '/\(\<\S\+\>\)\s\+\1\>'
364 " let pos = search('\(\<\S\+\>\)\s\+\1\>', "cw")
369 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
371 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
373 au Filetype python map <buffer> <F5> :!python % <CR>
375 " vimrc file for following the coding standards specified in PEP 7 & 8.
377 " Number of spaces that a pre-existing tab is equal to.
378 " For the amount of space used for a new tab use shiftwidth.
379 au Filetype python set shiftwidth=4
380 au Filetype python set expandtab
382 " Wrap text after a certain number of characters
383 au Filetype python set textwidth=79
385 let g:syntastic_python_checkers = ["pyflakes"]
387 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
389 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
391 "Opens the current file in ipe
392 au BufRead,BufNewFile *.ipe set filetype=ipe
393 au Filetype xml,ipe map <buffer> <M-o> :call OpenIn("ipe") <CR>
395 au Filetype xml let g:tagbar_sort = 0
396 let g:tagbar_type_xml = {
397 \ 'ctagstype' : 'xml',
403 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
405 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
407 "Opens the current file in ipe
408 au Filetype gnuplot map <buffer> <M-o> :call OpenIn("gnuplot -persist") <CR>
411 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
413 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
415 au BufRead,BufNewFile */.remind/* set filetype=remind
418 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
420 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
422 au BufRead,BufNewFile *.org set filetype=org
423 let g:org_todo_keywords=['TODO', 'FEEDBACK', 'VERIFY', '|', 'DONE', 'DELEGATED']
424 let g:org_todo_keyword_faces = [['FEEDBACK', 'magenta'], ['TODO', 'yellow']]
427 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
429 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
431 let g:instant_markdown_autostart = 0
432 let g:instant_markdown_slow = 1
433 au Filetype markdown map <buffer> <F5> :InstantMarkdownPreview<CR>
434 au Filetype markdown let g:tagbar_sort = 0
436 let g:tagbar_type_markdown = {
437 \ 'ctagstype' : 'markdown',
445 if executable('marktag')
446 let g:tagbar_type_markdown = {
447 \ 'ctagstype' : 'markdown',
448 \ 'ctagsbin' : 'marktag',
463 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
465 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
468 let g:deoplete#enable_at_startup = 1
471 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
473 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
475 let g:ycm_global_ycm_extra_conf = '~/.ycm_extra_conf.py'
476 let g:ycm_confirm_extra_conf = 0
478 let g:ycm_min_num_of_chars_for_completion = 4
479 let g:ycm_collect_identifiers_from_tags_files = 1
480 let g:ycm_autoclose_preview_window_after_completion = 1
482 let g:ycm_key_list_select_completion = ['<Down>']
483 nnoremap <buffer> <leader>jd :YcmCompleter GoToDefinitionElseDeclaration<CR>
485 let g:ycm_filetype_whitelist = { 'c' : 1, 'cpp' : 1, 'cs' : 1, 'objc' : 1, 'java' : 1, 'python' : 1 }
487 "let g:ycm_server_use_vim_stdout = 1
488 "let g:ycm_server_log_level = 'debug'
491 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
493 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
495 let g:syntastic_mode_map = { 'mode' : 'active', 'active_filetypes' : [], 'passive_filetypes' : ['html'] }
496 let g:ycm_show_diagnostics_ui = 0
497 let g:syntastic_c_checkers = ["cppcheck"]
498 let g:syntastic_cpp_checkers = g:syntastic_c_checkers
501 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
503 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
505 let g:signify_vcs_list = ['git']
510 if filereadable($HOME . "/.vimrc-local")
511 source ~/.vimrc-local
514 " Being able to load project specific vimrc files