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 Plut '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'
71 Plug 'thinca/vim-fontzoom'
72 Plug 'tpope/vim-ragtag'
73 Plug 'vim-scripts/CSApprox'
74 Plug 'vim-scripts/DetectIndent'
75 Plug 'vim-scripts/git_patch_tags.vim'
76 Plug 'vim-scripts/loremipsum'
79 autocmd! BufWritePost,BufEnter * Neomake
81 " If there is no vim-plug, try pathogen
83 runtime autoload/pathogen.vim
84 if exists("g:loaded_pathogen")
85 " Pathogen runtime path manipulation
86 call pathogen#runtime_append_all_bundles()
87 call pathogen#helptags()
93 set rtp^=/usr/share/vim/vimfiles
102 let $NVIM_TUI_ENABLE_TRUE_COLOR=1
104 let g:CSApprox_attr_map = { 'bold' : 'bold', 'italic' : 'underline', 'sp' : 'bg' }
106 colorscheme shuber-wombat
109 " Use the below highlight group when displaying bad whitespace is desired.
110 highlight BadWhitespace ctermbg=red guibg=red
111 " Make trailing whitespace be flagged as bad.
112 au Filetype python,tex,c,cpp,cs,objc,java,vim syn match BadWhitespace /\s\+$/ containedin=ALL
113 au Filetype python,tex,c,cpp,cs,objc,java,vim let g:airline#extensions#whitespace#enabled = 0
116 " Detect indentation, but otherwise set expandtab
117 if exists(":DetectIndent")
118 au BufReadPost * :DetectIndent
122 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
124 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
126 let g:airline_powerline_fonts = 0
127 let g:airline_theme = 'wombat'
129 let g:airline#extensions#tabline#enabled = 1
130 let g:airline#extensions#tagbar#enabled = 0
131 let g:airline#extensions#whitespace#enabled = 0
132 let g:airline#extensions#branch#enabled = 1
133 let g:airline#extensions#branch#use_vcscommand = 1
135 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
137 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
139 "Open current file with a specific program
140 function OpenIn(prog)
141 execute ":!" . a:prog . " % &"
145 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
147 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
149 nmap <s-PageDown> :bn<CR>
150 nmap <s-PageUp> :bp<CR>
152 map <a-c> <plug>NERDCommenterToggle
153 nmap <F9> :NERDTreeToggle<CR>
154 nmap <F10> :TagbarToggle<CR>
158 "vmap <c-s> <Esc><c-s>gv
159 "imap <c-s> <c-o><c-s>
162 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
164 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
166 "let fortran_free_source=1
167 au BufNewFile *.f90 set fortran_free_source=1
168 au Filetype fortran set cindent cst csto=0
171 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
172 " C, C++, C#, objc, java
173 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
175 au Filetype c,cpp,cs,objc,java set cindent cst csto=0
177 au Filetype c,cpp,cs,objc,java map <buffer> <F4> :cnext<CR>
178 au Filetype c,cpp,cs,objc,java map <buffer> <S-F4> :cprevious<CR>
180 au Filetype c,cpp,cs,objc set makeprg=make
181 au Filetype c,cpp,cs,objc map <buffer> <F7> :make<CR>
182 au Filetype java map <buffer> <F7> :!ant -f ../build.xml<CR>
185 runtime! plugin/fswitch.vim
187 au Filetype c,cpp,objc map <buffer> <F11> :vsplit<CR>:FSRight<CR>
188 au Filetype c,cpp,objc map <buffer> <S-F11> :FSHere<CR>
190 " Substitute lib <-> include, otherwise take the same directory
191 au BufEnter *.c* let b:fswitchlocs='reg:/lib/include/,rel:.'
192 au BufEnter *.h* let b:fswitchlocs='reg:/include/lib/,rel:.'
193 "au BufEnter *.c* let b:fswitchlocs='rel:.,rel:../inc*/**,rel:../../inc*/**'
195 au BufEnter *.cpp,*.cc,*.cxx let b:fswitchdst='h,hxx,hpp,hh'
196 au BufEnter *.h,*.hh,*.hxx let b:fswitchdst='cc,c,cxx,cpp'
198 au Filetype c,cpp,cs,objc,java map <buffer> <F11> :AS<CR>
199 au Filetype c,cpp,cs,objc,java map <buffer> <S-F11> :A<CR>
203 "Prepend the namespace to an identifier, e.g. 'std::' before 'map' excluding
204 "those in C/C++ comments.
205 function PrependCppNamespaceToIdent(ns, id)
207 " To match Not to match
211 "|/* */ /* */ id |/* */ // id
219 " In order to not match '* id' it is assumed that multi-line comment lines
220 " in the middle begin with a star.
222 " If #include and // and /* and ^* and :: is not prepend:
223 execute ':%s@\(\(#include\|\/\/\|\/\*\|^\s*\*[^/]\).*\|::\)\@<!\<' . a:id . '\>@' . a:ns . '::' . a:id . '@ge'
224 " If #include and // and :: is not prepend, but */ is, and no further /* or // are found
225 execute ':%s@\(\(#include\|\/\/\).*\)\@<!\*\/\(\/[^\/\*]\|[^\/]\)*\zs\(::\)\@<!\<' . a:id . '\>@' . a:ns . '::' . a:id . '@ge'
229 "Prepend STL namespace 'std::' to several identifiers
230 function PrependSTLNamespace()
231 " This list of identifier is not complete, but adding all of them is too
232 " much. We rather like to add identifieres that are 'typical' for C++.
233 " Others, like 'move' are likely to not be C++ specific. In this cases the
234 " user is asked to call PrependCppNamespaceToIdent by hand.
236 let id = id +['cin', 'cout', 'cerr', 'endl']
237 let id = id +['swap', 'sort', 'max', 'min']
238 let id = id +['vector', 'deque', 'list', 'map', 'multimap', 'set']
239 let id = id +['queue', 'stack', 'priority_queue']
240 let id = id +['ostream', 'istream', 'sstream']
241 let id = id +['pair', 'string']
244 call PrependCppNamespaceToIdent("std", i)
248 function EscapeHexToChar()
249 echo 'Call "x/Nxb addr" in GDB to print N bytes at addr'
251 execute '%s/\s*0x\(\x\x\)/\\x\1/g'
252 execute '%s/^\(.*\)$/"\1"/'
255 function InsertIncludeGuardsWithoutEndif()
256 let gatename = substitute(expand("%:t"), "\\.", "_", "g") . '_' . strpart(system('pwgen -c 16 1'), 0, 16)
257 execute "normal! i#ifndef " . gatename
258 execute "normal! o#define " . gatename
261 function AddIncludeGuards()
262 execute "normal! Go#endif"
264 call InsertIncludeGuardsWithoutEndif()
267 autocmd BufNewFile *.{h,hpp,hxx} call AddIncludeGuards()
270 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
272 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
274 au Filetype text set textwidth=80
275 au Filetype markddown set textwidth=80
276 "According to thunderbirds settings
277 au Filetype mail set textwidth=72
278 au Filetype mail set expandtab
280 "a and w reformat the paragraph automatically and a new paragraph
281 "is indicated by lines not ending with white-space
283 au Filetype mail,text set fo+=n spell
287 au Filetype mail syn match Statement /^\s*-*\s*>8\s*-*\s*$/
288 au Filetype mail syn match Statement /^\s*-*\s*8<\s*-*\s*$/
291 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
293 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
295 "au Filetype php set fo=tcqn
297 au Filetype php set spell
300 au Filetype php set textwidth=80
301 "au Filetype php set cindent
304 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
306 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
308 au BufRead,BufNewFile *.wxm set filetype=maxima
311 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
313 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
315 let g:LatexBox_split_side = "rightbelow"
316 "let g:LatexBox_split_resize = 1
317 let g:LatexBox_ref_pattern = '\c\\\a*ref\*\?\_\s*{'
319 let g:tex_flavor = "latex"
320 let g:LatexBox_output_type = "pdf"
321 let g:LatexBox_viewer = "okular"
322 let g:LatexBox_latexmk_async = 1
323 let g:LatexBox_latexmk_preview_continuously = 1
324 "let g:LatexBox_show_warnings = 0
325 let g:LatexBox_quickfix = 4
328 au Filetype tex set spell
331 au BufRead,BufNewFile *.cls set filetype=tex
332 au Filetype tex set textwidth=80
333 au Filetype tex set shiftwidth=2
334 au Filetype tex set smartindent
335 " Override Tagbar Toggle with LatexBox TOC
336 au Filetype tex nmap <buffer> <F10> :LatexTOCToggle<CR>
337 au Filetype tex nmap <buffer> <F11> :LatexLabels<CR>
341 function TexTransUmlaute()
342 execute ':%s/ü/\\\"u/ge'
343 execute ':%s/Ü/\\\"U/&'
344 execute ':%s/ö/\\\"o/&'
345 execute ':%s/Ö/\\\"O/&'
346 execute ':%s/ä/\\\"a/&'
347 execute ':%s/Ä/\\\"A/&'
348 execute ':%s/ß/\\\"s/&'
349 execute ':%s/²/\^2/&'
352 function FindWordRepeatings()
353 execute '/\(\<\S\+\>\)\s\+\1\>'
354 " let pos = search('\(\<\S\+\>\)\s\+\1\>', "cw")
359 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
361 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
363 au Filetype python map <buffer> <F5> :!python % <CR>
365 " vimrc file for following the coding standards specified in PEP 7 & 8.
367 " Number of spaces that a pre-existing tab is equal to.
368 " For the amount of space used for a new tab use shiftwidth.
369 au Filetype python set shiftwidth=4
370 au Filetype python set expandtab
372 " Wrap text after a certain number of characters
373 au Filetype python set textwidth=79
375 let g:syntastic_python_checkers = ["pyflakes"]
377 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
379 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
381 "Opens the current file in ipe
382 au BufRead,BufNewFile *.ipe set filetype=ipe
383 au Filetype xml,ipe map <buffer> <M-o> :call OpenIn("ipe") <CR>
385 au Filetype xml let g:tagbar_sort = 0
386 let g:tagbar_type_xml = {
387 \ 'ctagstype' : 'xml',
393 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
395 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
397 "Opens the current file in ipe
398 au Filetype gnuplot map <buffer> <M-o> :call OpenIn("gnuplot -persist") <CR>
401 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
403 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
405 au BufRead,BufNewFile */.remind/* set filetype=remind
408 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
410 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
412 au BufRead,BufNewFile *.org set filetype=org
413 let g:org_todo_keywords=['TODO', 'FEEDBACK', 'VERIFY', '|', 'DONE', 'DELEGATED']
414 let g:org_todo_keyword_faces = [['FEEDBACK', 'magenta'], ['TODO', 'yellow']]
417 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
419 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
421 let g:instant_markdown_autostart = 0
422 let g:instant_markdown_slow = 1
423 au Filetype markdown map <buffer> <F5> :InstantMarkdownPreview<CR>
424 au Filetype markdown let g:tagbar_sort = 0
426 let g:tagbar_type_markdown = {
427 \ 'ctagstype' : 'markdown',
435 if executable('marktag')
436 let g:tagbar_type_markdown = {
437 \ 'ctagstype' : 'markdown',
438 \ 'ctagsbin' : 'marktag',
453 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
455 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
457 let g:deoplete#enable_at_startup = 1
459 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
461 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
463 let g:ycm_global_ycm_extra_conf = '~/.ycm_extra_conf.py'
464 let g:ycm_confirm_extra_conf = 0
466 let g:ycm_min_num_of_chars_for_completion = 4
467 let g:ycm_collect_identifiers_from_tags_files = 1
468 let g:ycm_autoclose_preview_window_after_completion = 1
470 let g:ycm_key_list_select_completion = ['<Down>']
471 nnoremap <buffer> <leader>jd :YcmCompleter GoToDefinitionElseDeclaration<CR>
473 let g:ycm_filetype_whitelist = { 'c' : 1, 'cpp' : 1, 'cs' : 1, 'objc' : 1, 'java' : 1, 'python' : 1 }
475 "let g:ycm_server_use_vim_stdout = 1
476 "let g:ycm_server_log_level = 'debug'
479 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
481 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
483 let g:syntastic_mode_map = { 'mode' : 'active', 'active_filetypes' : [], 'passive_filetypes' : ['html'] }
484 let g:ycm_show_diagnostics_ui = 0
485 let g:syntastic_c_checkers = ["cppcheck"]
486 let g:syntastic_cpp_checkers = g:syntastic_c_checkers
489 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
491 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
493 let g:signify_vcs_list = ['git']
498 if filereadable($HOME . "/.vimrc-local")
499 source ~/.vimrc-local
502 " Being able to load project specific vimrc files