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
11 " Pathogen runtime path manipulation
12 "call pathogen#infect() "Using the infect method breaks ft detection
13 call pathogen#runtime_append_all_bundles()
16 "Activate syntax highlighting
18 "Activate filetype plugins: syntax highlighting, indentation, and more
19 filetype plugin indent on
23 set backspace=indent,eol,start
25 "vim-7 and newer has vimspell (spell checker) built in
27 set spelllang=de_at,en
29 "set colorcolumn=80,+1
33 "Set some properties for ctags, grep and the size of the
34 "most-left column for foldings
36 set grepprg=grep\ -nH\ $*
39 "Set incremental search and highlighted search results
44 "Power saving tip: powertop-homepage
45 let &guicursor = &guicursor . ",a:blinkon0"
46 "According to vim help -- enable mouse in xterm...
50 "Open current file with a specific program
52 execute ":!" . a:prog . " % &"
56 " Use the below highlight group when displaying bad whitespace is desired.
57 highlight BadWhitespace ctermbg=red guibg=red
58 " Make trailing whitespace be flagged as bad.
59 au Filetype python,tex,c,cpp,cs,objc,java syn match BadWhitespace /\s\+$/ containedin=ALL
61 set listchars=tab:»,trail:·,eol:$
67 au Filetype * :DetectIndent
68 "au Filetype python,tex,c,cpp,cs,objc,java :DetectIndent
69 "let g:detectindent_preferred_expandtab = 1
70 "let g:detectindent_preferred_indent = 4
76 let g:CSApprox_attr_map = { 'bold' : 'bold', 'italic' : '', 'sp' : '' }
77 colorscheme shuber-wombat
82 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
84 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
86 "let fortran_free_source=1
87 au BufNewFile *.f90 set fortran_free_source=1
88 au BufRead,BufNewFile *.INC set filetype=fortran
89 au Filetype fortran set cindent cst csto=0
94 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
96 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
98 au BufRead,BufNewFile */.irssi/logs/*.log set filetype=irssilog
101 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
102 " Easychair conference system review form
103 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
105 au BufRead,BufNewFile review_form_*.txt set filetype=easychair
106 au Syntax easychair runtime! syntax/easychair.vim
109 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
110 " C, C++, C#, objc, java
111 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
113 au Filetype c,cpp,cs,objc,java map <F4> :cnext <CR>
114 au Filetype c,cpp,cs,objc,java map <S-F4> :cprevious <CR>
115 au Filetype c,cpp,cs,objc,java map <F11> :AS <CR>
116 au Filetype c,cpp,cs,objc,java map <S-F11> :A <CR>
117 au Filetype c,cpp,cs,objc,java set cindent cst csto=0
118 au Filetype c,cpp,cs,objc map <F7> :make <CR>
119 au Filetype java map <F7> :!ant -f ../build.xml <CR>
120 au Filetype c,cpp,cs,obj set makeprg=make
123 "Adds STL prefix 'std::' to 'id'
124 function AddNamespaceDeclTo(ns, id)
125 echo "Add '" . a:ns . "' to " . a:id
126 "Line starts with a:id
127 execute ":%s!^\\(\\s*\\)" . a:id . "\\>!\\1" . a:ns . "::" . a:id . "!e"
128 "Line beginning, white space, not # or / (preprocessor or comment)
129 execute ":%s!^\\(\\s*[^#/].*[^:]\\)\\<" . a:id . "\\>!\\1" . a:ns . "::" . a:id . "!ge"
133 "Adds STL prefix 'std::' to several identifiers
134 function AddSTLNamespaceDecl()
135 call AddNamespaceDeclTo("std","cin")
136 call AddNamespaceDeclTo("std","cout")
137 call AddNamespaceDeclTo("std","cerr")
139 call AddNamespaceDeclTo("std","swap")
140 call AddNamespaceDeclTo("std","sort")
141 call AddNamespaceDeclTo("std","max")
142 call AddNamespaceDeclTo("std","min")
144 call AddNamespaceDeclTo("std","deque")
145 call AddNamespaceDeclTo("std","endl")
146 call AddNamespaceDeclTo("std","list")
147 call AddNamespaceDeclTo("std","map")
148 call AddNamespaceDeclTo("std","multimap")
149 call AddNamespaceDeclTo("std","ostream")
150 call AddNamespaceDeclTo("std","pair")
151 call AddNamespaceDeclTo("std","priority_queue")
152 call AddNamespaceDeclTo("std","set")
153 call AddNamespaceDeclTo("std","queue")
154 call AddNamespaceDeclTo("std","stack")
155 call AddNamespaceDeclTo("std","string")
156 call AddNamespaceDeclTo("std","vector")
160 function EscapeHexToChar()
161 echo 'Call "x/Nxb addr" in GDB to print N bytes at addr'
163 execute '%s/\s*0x\(\x\x\)/\\x\1/g'
164 execute '%s/^\(.*\)$/"\1"/'
169 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
171 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
173 au Filetype text set textwidth=80
174 "According to thunderbirds settings
175 au Filetype mail set textwidth=72
177 "a and w reformat the paragraph automatically and a new paragraph
178 "is indicated by lines not ending with white-space
180 au Filetype mail,text set fo+=n spell
184 au Filetype mail syn match Statement /^\s*-*\s*>8\s*-*\s*$/
185 au Filetype mail syn match Statement /^\s*-*\s*8<\s*-*\s*$/
189 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
191 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
193 "au Filetype php set fo=tcqn
195 au Filetype php set spell
198 au Filetype php set textwidth=80
199 "au Filetype php set cindent
204 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
206 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
208 au BufRead,BufNewFile *.cls set filetype=tex
209 au Filetype tex set textwidth=80
212 function TexTransUmlaute()
213 execute ':%s/ü/\\\"u/ge'
214 execute ':%s/Ü/\\\"U/&'
215 execute ':%s/ö/\\\"o/&'
216 execute ':%s/Ö/\\\"O/&'
217 execute ':%s/ä/\\\"a/&'
218 execute ':%s/Ä/\\\"A/&'
219 execute ':%s/ß/\\\"s/&'
220 execute ':%s/²/\^2/&'
224 function FindWordRepeatings()
225 execute '/\(\<\S\+\>\)\s\+\1\>'
226 " let pos = search('\(\<\S\+\>\)\s\+\1\>', "cw")
231 let g:tex_flavor = "latex"
232 let g:LatexBox_viewer="okular"
233 let g:LatexBox_latexmk_options="-pvc"
235 au Filetype tex set smartindent
237 au Filetype tex map! ,b \begin{}<Esc>i
238 au Filetype tex map! ,e <esc>:call TexClosePrev(0)<cr>a<cr>
239 au Filetype tex map! ,i \begin{itemize}<Return>\end{itemize}<ESC>O\item
240 au Filetype tex map! ,f \begin{frame}<Return>\end{frame}<ESC>O\frametitle{
241 au Filetype tex map! ,p \begin{figure}<Return>\end{figure}<ESC>O\centering<Return>\includegraphics{
246 au Filetype tex set spell
251 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
253 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
255 au Filetype python map <F5> :!python % <CR>
258 " vimrc file for following the coding standards specified in PEP 7 & 8.
260 " Number of spaces that a pre-existing tab is equal to.
261 " For the amount of space used for a new tab use shiftwidth.
262 au Filetype python set shiftwidth=4
263 au Filetype python set expandtab
265 " Wrap text after a certain number of characters
266 au BufRead,BufNewFile *.py,*.pyw set textwidth=79
271 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
273 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
275 "Opens the current file in ipe
276 au Filetype xml map <M-o> :call OpenIn("ipe") <CR>
279 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
281 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
284 au BufRead,BufNewFile *.plt set filetype=gnuplot
285 au BufRead,BufNewFile *.plot set filetype=gnuplot
286 au BufRead,BufNewFile *.gnuplot set filetype=gnuplot
288 "Opens the current file in ipe
289 au Filetype gnuplot map <M-o> :call OpenIn("gnuplot -persist") <CR>
293 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
295 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
297 let g:EnhCommentifyUseAltKeys = 'Yes'
301 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
303 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
305 "function InsertTabWrapper()
306 " let col = col('.') - 1
307 " if !col || getline('.')[col - 1] !~ '\k'
314 " Remap the tab key to select action with InsertTabWrapper
315 "inoremap <C-space> <c-r>=InsertTabWrapper()<cr>
317 let g:SuperTabMappingForward = "<C-space>"
318 let g:SuperTabDefaultCompletionType = 'context'
319 "let g:SuperTabDefaultCompletionType = '<c-x><c-u>'
323 if filereadable($HOME . "/.vimrc-local")
324 source ~/.vimrc-local