1 " Purpose: My personal .vimrc
4 "Essential resources for vim users
5 " - vim.sf.net -- find tips and scripts for vim and gvim
7 "By calling ":help keyword" you get help for the specific
15 set backspace=indent,eol,start
18 set grepprg=grep\ -nH\ $*
27 set listchars=tab:»,trail:·,eol:$
34 set spelllang=de_at,en
39 " Pathogen runtime path manipulation
40 "call pathogen#infect() "Using the infect method breaks ft detection
42 call pathogen#runtime_append_all_bundles()
43 call pathogen#helptags()
46 filetype plugin indent on
49 "Power saving tip: powertop-homepage
50 let &guicursor = &guicursor . ",a:blinkon0"
51 "According to vim help -- enable mouse in xterm...
56 let g:CSApprox_attr_map = { 'bold' : 'bold', 'italic' : '', 'sp' : '' }
57 colorscheme shuber-wombat
60 " Use the below highlight group when displaying bad whitespace is desired.
61 highlight BadWhitespace ctermbg=red guibg=red
62 " Make trailing whitespace be flagged as bad.
63 au Filetype python,tex,c,cpp,cs,objc,java,vim syn match BadWhitespace /\s\+$/ containedin=ALL
66 if exists(":DetectIndent")
67 au BufReadPost * :DetectIndent
71 let g:syntastic_mode_map = { 'mode' : 'active', 'active_filetypes' : [], 'passive_filetypes' : ['html'] }
74 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
76 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
78 "Open current file with a specific program
80 execute ":!" . a:prog . " % &"
84 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
86 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
88 map <a-c> <plug>NERDCommenterToggle
92 vmap <c-s> <Esc><c-s>gv
96 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
98 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
100 "let fortran_free_source=1
101 au BufNewFile *.f90 set fortran_free_source=1
102 au Filetype fortran set cindent cst csto=0
105 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
106 " C, C++, C#, objc, java
107 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
109 au Filetype c,cpp,cs,objc,java map <F4> :cnext <CR>
110 au Filetype c,cpp,cs,objc,java map <S-F4> :cprevious <CR>
111 au Filetype c,cpp,cs,objc,java map <F11> :AS <CR>
112 au Filetype c,cpp,cs,objc,java map <S-F11> :A <CR>
113 au Filetype c,cpp,cs,objc,java set cindent cst csto=0
114 au Filetype c,cpp,cs,objc map <F7> :make <CR>
115 au Filetype java map <F7> :!ant -f ../build.xml <CR>
116 au Filetype c,cpp,cs,obj set makeprg=make
119 "Prepend the namespace to an identifier, e.g. 'std::' before 'map' excluding
120 "those in C/C++ comments.
121 function PrependCppNamespaceToIdent(ns, id)
123 " To match Not to match
127 "|/* */ /* */ id |/* */ // id
135 " In order to not match '* id' it is assumed that multi-line comment lines
136 " in the middle begin with a star.
138 " If #include and // and /* and ^* and :: is not prepend:
139 execute ':%s@\(\(#include\|\/\/\|\/\*\|^\s*\*[^/]\).*\|::\)\@<!\<' . a:id . '\>@' . a:ns . '::' . a:id . '@ge'
140 " If #include and // and :: is not prepend, but */ is, and no further /* or // are found
141 execute ':%s@\(\(#include\|\/\/\).*\)\@<!\*\/\(\/[^\/\*]\|[^\/]\)*\zs\(::\)\@<!\<' . a:id . '\>@' . a:ns . '::' . a:id . '@ge'
145 "Prepend STL namespace 'std::' to several identifiers
146 function PrependSTLNamespace()
147 " This list of identifier is not complete, but adding all of them is too
148 " much. We rather like to add identifieres that are 'typical' for C++.
149 " Others, like 'move' are likely to not be C++ specific. In this cases the
150 " user is asked to call PrependCppNamespaceToIdent by hand.
152 let id = id +['cin', 'cout', 'cerr', 'endl']
153 let id = id +['swap', 'sort', 'max', 'min']
154 let id = id +['vector', 'deque', 'list', 'map', 'multimap', 'set']
155 let id = id +['queue', 'stack', 'priority_queue']
156 let id = id +['ostream', 'istream', 'sstream']
157 let id = id +['pair', 'string']
160 call PrependCppNamespaceToIdent("std", i)
164 function EscapeHexToChar()
165 echo 'Call "x/Nxb addr" in GDB to print N bytes at addr'
167 execute '%s/\s*0x\(\x\x\)/\\x\1/g'
168 execute '%s/^\(.*\)$/"\1"/'
171 function InsertIncludeGuardsWithoutEndif()
172 let gatename = substitute(expand("%:t"), "\\.", "_", "g") . '_' . strpart(system('pwgen -c 16 1'), 0, 16)
173 execute "normal! i#ifndef " . gatename
174 execute "normal! o#define " . gatename
177 function AddIncludeGuards()
178 execute "normal! Go#endif"
180 call InsertIncludeGuardsWithoutEndif()
183 autocmd BufNewFile *.{h,hpp} call AddIncludeGuards()
186 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
188 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
190 au Filetype text set textwidth=80
191 "According to thunderbirds settings
192 au Filetype mail set textwidth=72
193 au Filetype mail set expandtab
195 "a and w reformat the paragraph automatically and a new paragraph
196 "is indicated by lines not ending with white-space
198 au Filetype mail,text set fo+=n spell
202 au Filetype mail syn match Statement /^\s*-*\s*>8\s*-*\s*$/
203 au Filetype mail syn match Statement /^\s*-*\s*8<\s*-*\s*$/
206 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
208 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
210 "au Filetype php set fo=tcqn
212 au Filetype php set spell
215 au Filetype php set textwidth=80
216 "au Filetype php set cindent
219 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
221 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
223 au BufRead,BufNewFile *.cls set filetype=tex
224 au Filetype tex set textwidth=80
227 function TexTransUmlaute()
228 execute ':%s/ü/\\\"u/ge'
229 execute ':%s/Ü/\\\"U/&'
230 execute ':%s/ö/\\\"o/&'
231 execute ':%s/Ö/\\\"O/&'
232 execute ':%s/ä/\\\"a/&'
233 execute ':%s/Ä/\\\"A/&'
234 execute ':%s/ß/\\\"s/&'
235 execute ':%s/²/\^2/&'
238 function FindWordRepeatings()
239 execute '/\(\<\S\+\>\)\s\+\1\>'
240 " let pos = search('\(\<\S\+\>\)\s\+\1\>', "cw")
244 let g:tex_flavor = "latex"
245 let g:LatexBox_viewer="okular"
246 let g:LatexBox_latexmk_options="-pvc"
248 au Filetype tex set smartindent
251 au Filetype tex set spell
255 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
257 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
259 au Filetype python map <F5> :!python % <CR>
261 " vimrc file for following the coding standards specified in PEP 7 & 8.
263 " Number of spaces that a pre-existing tab is equal to.
264 " For the amount of space used for a new tab use shiftwidth.
265 au Filetype python set shiftwidth=4
266 au Filetype python set expandtab
268 " Wrap text after a certain number of characters
269 au Filetype python set textwidth=79
272 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
274 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
276 "Opens the current file in ipe
277 au Filetype xml map <M-o> :call OpenIn("ipe") <CR>
280 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
282 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
284 "Opens the current file in ipe
285 au Filetype gnuplot map <M-o> :call OpenIn("gnuplot -persist") <CR>
288 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
290 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
292 let g:ycm_min_num_of_chars_for_completion = 999
293 let g:ycm_key_list_select_completion = ['<Down>']
297 if filereadable($HOME . "/.vimrc-local")
298 source ~/.vimrc-local