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
32 "Set some properties for ctags, grep and the size of the
33 "most-left column for foldings
35 set grepprg=grep\ -nH\ $*
38 "Set incremental search and highlighted search results
43 "Power saving tip: powertop-homepage
44 let &guicursor = &guicursor . ",a:blinkon0"
45 "According to vim help -- enable mouse in xterm...
49 "Open current file with a specific program
51 execute ":!" . a:prog . " % &"
55 " Use the below highlight group when displaying bad whitespace is desired.
56 highlight BadWhitespace ctermbg=red guibg=red
57 " Make trailing whitespace be flagged as bad.
58 au Filetype python,tex,c,cpp,cs,objc,java syn match BadWhitespace /\s\+$/ containedin=ALL
60 set listchars=tab:»,trail:·,eol:$
65 au Filetype python,tex,c,cpp,cs,objc,java :DetectIndent
66 "let g:detectindent_preferred_expandtab = 1
67 "let g:detectindent_preferred_indent = 4
70 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
72 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
74 "let fortran_free_source=1
75 au BufNewFile *.f90 set fortran_free_source=1
76 au BufRead,BufNewFile *.INC set filetype=fortran
77 au Filetype fortran set cindent cst csto=0
82 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
84 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
86 au BufRead,BufNewFile */.irssi/logs/*.log set filetype=irssilog
89 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
90 " Easychair conference system review form
91 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
93 au BufRead,BufNewFile review_form_*.txt set filetype=easychair
94 au Syntax easychair runtime! syntax/easychair.vim
97 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
98 " C, C++, C#, objc, java
99 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
101 au Filetype c,cpp,cs,objc,java map <F4> :cnext <CR>
102 au Filetype c,cpp,cs,objc,java map <S-F4> :cprevious <CR>
103 au Filetype c,cpp,cs,objc,java map <F11> :AS <CR>
104 au Filetype c,cpp,cs,objc,java map <S-F11> :A <CR>
105 au Filetype c,cpp,cs,objc,java set cindent cst csto=0
106 au Filetype c,cpp,cs,objc map <F7> :make <CR>
107 au Filetype java map <F7> :!ant -f ../build.xml <CR>
108 au Filetype c,cpp,cs,obj set makeprg=make
109 au Filetype c,cpp,cs,obj set shiftwidth=4
112 "Adds STL prefix 'std::' to 'id'
113 function AddNamespaceDeclTo(ns, id)
114 echo "Add '" . a:ns . "' to " . a:id
115 "Line starts with a:id
116 execute ":%s!^\\(\\s*\\)" . a:id . "\\>!\\1" . a:ns . "::" . a:id . "!e"
117 "Line beginning, white space, not # or / (preprocessor or comment)
118 execute ":%s!^\\(\\s*[^#/].*[^:]\\)\\<" . a:id . "\\>!\\1" . a:ns . "::" . a:id . "!ge"
122 "Adds STL prefix 'std::' to several identifiers
123 function AddSTLNamespaceDecl()
124 call AddNamespaceDeclTo("std","cin")
125 call AddNamespaceDeclTo("std","cout")
126 call AddNamespaceDeclTo("std","cerr")
128 call AddNamespaceDeclTo("std","swap")
129 call AddNamespaceDeclTo("std","sort")
130 call AddNamespaceDeclTo("std","max")
131 call AddNamespaceDeclTo("std","min")
133 call AddNamespaceDeclTo("std","deque")
134 call AddNamespaceDeclTo("std","endl")
135 call AddNamespaceDeclTo("std","list")
136 call AddNamespaceDeclTo("std","map")
137 call AddNamespaceDeclTo("std","multimap")
138 call AddNamespaceDeclTo("std","ostream")
139 call AddNamespaceDeclTo("std","pair")
140 call AddNamespaceDeclTo("std","priority_queue")
141 call AddNamespaceDeclTo("std","set")
142 call AddNamespaceDeclTo("std","queue")
143 call AddNamespaceDeclTo("std","stack")
144 call AddNamespaceDeclTo("std","string")
145 call AddNamespaceDeclTo("std","vector")
149 function EscapeHexToChar()
150 echo 'Call "x/Nxb addr" in GDB to print N bytes at addr'
152 execute '%s/\s*0x\(\x\x\)/\\x\1/g'
153 execute '%s/^\(.*\)$/"\1"/'
158 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
160 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
162 au Filetype text set textwidth=80
163 "According to thunderbirds settings
164 au Filetype mail set textwidth=72
166 "a and w reformat the paragraph automatically and a new paragraph
167 "is indicated by lines not ending with white-space
169 au Filetype mail,text set fo+=n spell
173 au Filetype mail syn match Statement /^\s*-*\s*>8\s*-*\s*$/
174 au Filetype mail syn match Statement /^\s*-*\s*8<\s*-*\s*$/
178 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
180 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
182 "au Filetype php set fo=tcqn
184 au Filetype php set spell
187 au Filetype php set textwidth=80
188 "au Filetype php set cindent
193 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
195 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
197 au BufRead,BufNewFile *.cls set filetype=tex
198 au Filetype tex set textwidth=80
201 function TexTransUmlaute()
202 execute ':%s/ü/\\\"u/ge'
203 execute ':%s/Ü/\\\"U/&'
204 execute ':%s/ö/\\\"o/&'
205 execute ':%s/Ö/\\\"O/&'
206 execute ':%s/ä/\\\"a/&'
207 execute ':%s/Ä/\\\"A/&'
208 execute ':%s/ß/\\\"s/&'
209 execute ':%s/²/\^2/&'
213 function FindWordRepeatings()
214 execute '/\(\<\S\+\>\)\s\+\1\>'
215 " let pos = search('\(\<\S\+\>\)\s\+\1\>', "cw")
220 let g:tex_flavor = "latex"
221 let g:LatexBox_viewer="okular"
222 let g:LatexBox_latexmk_options="-pvc"
224 au Filetype tex set smartindent
226 au Filetype tex set shiftwidth=4
228 au Filetype tex map! ,b \begin{}<Esc>i
229 au Filetype tex map! ,e <esc>:call TexClosePrev(0)<cr>a<cr>
230 au Filetype tex map! ,i \begin{itemize}<Return>\end{itemize}<ESC>O\item
231 au Filetype tex map! ,f \begin{frame}<Return>\end{frame}<ESC>O\frametitle{
232 au Filetype tex map! ,p \begin{figure}<Return>\end{figure}<ESC>O\centering<Return>\includegraphics{
237 au Filetype tex set spell
242 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
244 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
246 au Filetype python map <F5> :!python % <CR>
249 " vimrc file for following the coding standards specified in PEP 7 & 8.
251 " Number of spaces that a pre-existing tab is equal to.
252 " For the amount of space used for a new tab use shiftwidth.
253 au Filetype python set shiftwidth=4
254 au Filetype python set expandtab
256 " Wrap text after a certain number of characters
257 au BufRead,BufNewFile *.py,*.pyw set textwidth=79
262 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
264 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
266 "Opens the current file in ipe
267 au Filetype xml map <M-o> :call OpenIn("ipe") <CR>
270 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
272 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
275 au BufRead,BufNewFile *.plt set filetype=gnuplot
276 au BufRead,BufNewFile *.plot set filetype=gnuplot
277 au BufRead,BufNewFile *.gnuplot set filetype=gnuplot
279 "Opens the current file in ipe
280 au Filetype gnuplot map <M-o> :call OpenIn("gnuplot -persist") <CR>
284 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
286 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
288 let g:EnhCommentifyUseAltKeys = 'Yes'
292 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
294 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
296 "function InsertTabWrapper()
297 " let col = col('.') - 1
298 " if !col || getline('.')[col - 1] !~ '\k'
305 " Remap the tab key to select action with InsertTabWrapper
306 "inoremap <C-space> <c-r>=InsertTabWrapper()<cr>
308 let g:SuperTabMappingForward = "<C-space>"
309 let g:SuperTabDefaultCompletionType = 'context'
310 "let g:SuperTabDefaultCompletionType = '<c-x><c-u>'
313 source ~/.vimrc-local