1 " Purpose: My personal .vimrc
4 "profile start /tmp/profile.log
12 set backspace=indent,eol,start
15 set grepprg=grep\ -nH\ $*
24 set listchars=tab:»,trail:·,eol:$
33 set spelllang=de_at,en
38 set wildmode=longest,list:longest
42 " Pathogen runtime path manipulation
43 "call pathogen#infect() "Using the infect method breaks ft detection
45 call pathogen#runtime_append_all_bundles()
46 call pathogen#helptags()
49 filetype plugin indent on
52 "Power saving tip: powertop-homepage
53 let &guicursor = &guicursor . ",a:blinkon0"
54 "According to vim help -- enable mouse in xterm...
59 let g:CSApprox_attr_map = { 'bold' : 'bold', 'italic' : '', 'sp' : '' }
60 colorscheme shuber-wombat
63 " Use the below highlight group when displaying bad whitespace is desired.
64 highlight BadWhitespace ctermbg=red guibg=red
65 " Make trailing whitespace be flagged as bad.
66 au Filetype python,tex,c,cpp,cs,objc,java,vim syn match BadWhitespace /\s\+$/ containedin=ALL
67 au Filetype python,tex,c,cpp,cs,objc,java,vim let g:airline#extensions#whitespace#enabled = 0
70 " Detect indentation, but otherwise set expandtab
71 if exists(":DetectIndent")
72 au BufReadPost * :DetectIndent
76 let g:syntastic_mode_map = { 'mode' : 'active', 'active_filetypes' : [], 'passive_filetypes' : ['html'] }
79 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
81 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
83 let g:airline_powerline_fonts = 0
84 let g:airline_theme = 'wombat'
86 let g:airline#extensions#tabline#enabled = 1
87 let g:airline#extensions#tagbar#enabled = 0
88 let g:airline#extensions#whitespace#enabled = 0
89 let g:airline#extensions#branch#enabled = 0
90 let g:airline#extensions#branch#use_vcscommand = 1
92 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
94 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
96 "Open current file with a specific program
98 execute ":!" . a:prog . " % &"
102 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
104 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
106 map <a-c> <plug>NERDCommenterToggle
107 nmap <F9> :NERDTreeToggle<CR>
108 nmap <F10> :TagbarToggle<CR>
112 vmap <c-s> <Esc><c-s>gv
113 imap <c-s> <c-o><c-s>
116 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
118 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
120 "let fortran_free_source=1
121 au BufNewFile *.f90 set fortran_free_source=1
122 au Filetype fortran set cindent cst csto=0
125 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
126 " C, C++, C#, objc, java
127 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
129 au Filetype c,cpp,cs,objc,java map <F4> :cnext <CR>
130 au Filetype c,cpp,cs,objc,java map <S-F4> :cprevious <CR>
131 au Filetype c,cpp,cs,objc,java map <F11> :AS <CR>
132 au Filetype c,cpp,cs,objc,java map <S-F11> :A <CR>
133 au Filetype c,cpp,cs,objc,java set cindent cst csto=0
134 au Filetype c,cpp,cs,objc map <F7> :make <CR>
135 au Filetype java map <F7> :!ant -f ../build.xml <CR>
136 au Filetype c,cpp,cs,obj set makeprg=make
139 "Prepend the namespace to an identifier, e.g. 'std::' before 'map' excluding
140 "those in C/C++ comments.
141 function PrependCppNamespaceToIdent(ns, id)
143 " To match Not to match
147 "|/* */ /* */ id |/* */ // id
155 " In order to not match '* id' it is assumed that multi-line comment lines
156 " in the middle begin with a star.
158 " If #include and // and /* and ^* and :: is not prepend:
159 execute ':%s@\(\(#include\|\/\/\|\/\*\|^\s*\*[^/]\).*\|::\)\@<!\<' . a:id . '\>@' . a:ns . '::' . a:id . '@ge'
160 " If #include and // and :: is not prepend, but */ is, and no further /* or // are found
161 execute ':%s@\(\(#include\|\/\/\).*\)\@<!\*\/\(\/[^\/\*]\|[^\/]\)*\zs\(::\)\@<!\<' . a:id . '\>@' . a:ns . '::' . a:id . '@ge'
165 "Prepend STL namespace 'std::' to several identifiers
166 function PrependSTLNamespace()
167 " This list of identifier is not complete, but adding all of them is too
168 " much. We rather like to add identifieres that are 'typical' for C++.
169 " Others, like 'move' are likely to not be C++ specific. In this cases the
170 " user is asked to call PrependCppNamespaceToIdent by hand.
172 let id = id +['cin', 'cout', 'cerr', 'endl']
173 let id = id +['swap', 'sort', 'max', 'min']
174 let id = id +['vector', 'deque', 'list', 'map', 'multimap', 'set']
175 let id = id +['queue', 'stack', 'priority_queue']
176 let id = id +['ostream', 'istream', 'sstream']
177 let id = id +['pair', 'string']
180 call PrependCppNamespaceToIdent("std", i)
184 function EscapeHexToChar()
185 echo 'Call "x/Nxb addr" in GDB to print N bytes at addr'
187 execute '%s/\s*0x\(\x\x\)/\\x\1/g'
188 execute '%s/^\(.*\)$/"\1"/'
191 function InsertIncludeGuardsWithoutEndif()
192 let gatename = substitute(expand("%:t"), "\\.", "_", "g") . '_' . strpart(system('pwgen -c 16 1'), 0, 16)
193 execute "normal! i#ifndef " . gatename
194 execute "normal! o#define " . gatename
197 function AddIncludeGuards()
198 execute "normal! Go#endif"
200 call InsertIncludeGuardsWithoutEndif()
203 autocmd BufNewFile *.{h,hpp,hxx} call AddIncludeGuards()
206 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
208 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
210 au Filetype text set textwidth=80
211 "According to thunderbirds settings
212 au Filetype mail set textwidth=72
213 au Filetype mail set expandtab
215 "a and w reformat the paragraph automatically and a new paragraph
216 "is indicated by lines not ending with white-space
218 au Filetype mail,text set fo+=n spell
222 au Filetype mail syn match Statement /^\s*-*\s*>8\s*-*\s*$/
223 au Filetype mail syn match Statement /^\s*-*\s*8<\s*-*\s*$/
226 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
228 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
230 "au Filetype php set fo=tcqn
232 au Filetype php set spell
235 au Filetype php set textwidth=80
236 "au Filetype php set cindent
239 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
241 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
243 au BufRead,BufNewFile *.wxm set filetype=maxima
246 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
248 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
250 au BufRead,BufNewFile *.cls set filetype=tex
251 au Filetype tex set textwidth=80
254 function TexTransUmlaute()
255 execute ':%s/ü/\\\"u/ge'
256 execute ':%s/Ü/\\\"U/&'
257 execute ':%s/ö/\\\"o/&'
258 execute ':%s/Ö/\\\"O/&'
259 execute ':%s/ä/\\\"a/&'
260 execute ':%s/Ä/\\\"A/&'
261 execute ':%s/ß/\\\"s/&'
262 execute ':%s/²/\^2/&'
265 function FindWordRepeatings()
266 execute '/\(\<\S\+\>\)\s\+\1\>'
267 " let pos = search('\(\<\S\+\>\)\s\+\1\>', "cw")
271 let g:tex_flavor = "latex"
272 let g:LatexBox_output_type = "pdf"
273 let g:LatexBox_viewer = "okular"
274 let g:LatexBox_latexmk_async = 1
275 let g:LatexBox_latexmk_preview_continuously = 1
276 let g:LatexBox_show_warnings = 0
277 let g:LatexBox_quickfix = 2
279 au Filetype tex set smartindent
282 au Filetype tex set spell
286 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
288 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
290 au Filetype python map <F5> :!python % <CR>
292 " vimrc file for following the coding standards specified in PEP 7 & 8.
294 " Number of spaces that a pre-existing tab is equal to.
295 " For the amount of space used for a new tab use shiftwidth.
296 au Filetype python set shiftwidth=4
297 au Filetype python set expandtab
299 " Wrap text after a certain number of characters
300 au Filetype python set textwidth=79
303 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
305 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
307 "Opens the current file in ipe
308 au Filetype xml map <M-o> :call OpenIn("ipe") <CR>
311 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
313 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
315 "Opens the current file in ipe
316 au Filetype gnuplot map <M-o> :call OpenIn("gnuplot -persist") <CR>
319 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
321 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
323 au BufRead,BufNewFile */.remind/* set filetype=remind
326 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
328 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
330 "let g:ycm_path_to_python_interpreter = '/usr/bin/python'
331 let g:ycm_global_ycm_extra_conf = '/home/shuber/.ycm_extra_conf.py'
332 let g:ycm_min_num_of_chars_for_completion = 999
333 let g:ycm_key_list_select_completion = ['<Down>']
334 let g:ycm_collect_identifiers_from_tags_files = 1
335 let g:ycm_autoclose_preview_window_after_completion = 1
336 nnoremap <leader>jd :YcmCompleter GoToDefinitionElseDeclaration<CR>
338 "let g:ycm_server_use_vim_stdout = 1
339 "let g:ycm_server_log_level = 'debug'
342 if filereadable($HOME . "/.vimrc-local")
343 source ~/.vimrc-local
346 " Being able to load project specific vimrc files