set shiftwidth=4
if version >= 703
- set spelllang=de_at,en
- set tabpagemax=20
- set colorcolumn=+1
+ set spelllang=de_at,en
+ set tabpagemax=20
+ set colorcolumn=+1
endif
" Pathogen runtime path manipulation
" Use the below highlight group when displaying bad whitespace is desired.
highlight BadWhitespace ctermbg=red guibg=red
" Make trailing whitespace be flagged as bad.
-au Filetype python,tex,c,cpp,cs,objc,java syn match BadWhitespace /\s\+$/ containedin=ALL
+au Filetype python,tex,c,cpp,cs,objc,java,vim syn match BadWhitespace /\s\+$/ containedin=ALL
if exists(":DetectIndent")
- au BufReadPost * :DetectIndent
+ au BufReadPost * :DetectIndent
endif
"Open current file with a specific program
function OpenIn(prog)
- execute ":!" . a:prog . " % &"
+ execute ":!" . a:prog . " % &"
endfunction
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"let fortran_free_source=1
-au BufNewFile *.f90 set fortran_free_source=1
-au Filetype fortran set cindent cst csto=0
+au BufNewFile *.f90 set fortran_free_source=1
+au Filetype fortran set cindent cst csto=0
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
au Filetype c,cpp,cs,obj set makeprg=make
-"Adds STL prefix 'std::' to 'id'
-function AddNamespaceDeclTo(ns, id)
- echo "Add '" . a:ns . "' to " . a:id
- "Line starts with a:id
- execute ":%s!^\\(\\s*\\)" . a:id . "\\>!\\1" . a:ns . "::" . a:id . "!e"
- "Line beginning, white space, not # or / (preprocessor or comment)
- execute ":%s!^\\(\\s*[^#/].*[^:]\\)\\<" . a:id . "\\>!\\1" . a:ns . "::" . a:id . "!ge"
+"Prepend the namespace to an identifier, e.g. 'std::' before 'map' excluding
+"those in C/C++ comments.
+function PrependCppNamespaceToIdent(ns, id)
+
+ " To match Not to match
+ "
+ "|id |// id
+ "| id |// /* */ id
+ "|/* */ /* */ id |/* */ // id
+ "|id /* */ |/* id
+ "|*/ id | * id
+ " |/* id */
+ " |::id
+ " |/**/ ::id
+ "
+ " In order to not match '* id' it is assumed that multi-line comment lines
+ " in the middle begin with a star.
+
+ " If // and /* and ^* and :: is not prepend:
+ execute ':%s_\(\(\/\/\|\/\*\|^\s*\*[^/]\).*\|::\)\@<!\<' . a:id . '\>_' . a:ns . '::' . a:id . '_ge'
+ " If // and :: is not prepend, but */ is, and no further /* or // are found
+ execute ':%s_\(\/\/.*\)\@<!\*\/\(\/[^\/\*]\|[^\/]\)*\zs\(::\)\@<!\<' . a:id . '\>_' . a:ns . '::' . a:id . '_ge'
+
endfunction
-"Adds STL prefix 'std::' to several identifiers
-function AddSTLNamespaceDecl()
- call AddNamespaceDeclTo("std","cin")
- call AddNamespaceDeclTo("std","cout")
- call AddNamespaceDeclTo("std","cerr")
-
- call AddNamespaceDeclTo("std","swap")
- call AddNamespaceDeclTo("std","sort")
- call AddNamespaceDeclTo("std","max")
- call AddNamespaceDeclTo("std","min")
-
- call AddNamespaceDeclTo("std","deque")
- call AddNamespaceDeclTo("std","endl")
- call AddNamespaceDeclTo("std","list")
- call AddNamespaceDeclTo("std","map")
- call AddNamespaceDeclTo("std","multimap")
- call AddNamespaceDeclTo("std","ostream")
- call AddNamespaceDeclTo("std","pair")
- call AddNamespaceDeclTo("std","priority_queue")
- call AddNamespaceDeclTo("std","set")
- call AddNamespaceDeclTo("std","queue")
- call AddNamespaceDeclTo("std","stack")
- call AddNamespaceDeclTo("std","string")
- call AddNamespaceDeclTo("std","vector")
+"Prepend STL namespace 'std::' to several identifiers
+function PrependSTLNamespace()
+ let id = []
+ let id = id +['cin', 'cout', 'cerr', 'endl']
+ let id = id +['swap', 'sort', 'max', 'min']
+ let id = id +['vector', 'deque', 'list', 'map', 'multimap', 'set']
+ let id = id +['queue', 'stack', 'priority_queue']
+ let id = id +['ostream', 'istream']
+ let id = id +['pair', 'string']
+ let id = ['map']
+
+ for i in id
+ call PrependCppNamespaceToIdent("std", i)
+ endfor
endfunction
function EscapeHexToChar()
- echo 'Call "x/Nxb addr" in GDB to print N bytes at addr'
- execute '%s/^.*://'
- execute '%s/\s*0x\(\x\x\)/\\x\1/g'
- execute '%s/^\(.*\)$/"\1"/'
+ echo 'Call "x/Nxb addr" in GDB to print N bytes at addr'
+ execute '%s/^.*://'
+ execute '%s/\s*0x\(\x\x\)/\\x\1/g'
+ execute '%s/^\(.*\)$/"\1"/'
endfunction
"a and w reformat the paragraph automatically and a new paragraph
"is indicated by lines not ending with white-space
if version>=700
- au Filetype mail,text set fo+=n spell
+ au Filetype mail,text set fo+=n spell
endif
"Scissor line
"au Filetype php set fo=tcqn
if version >= 700
- au Filetype php set spell
+ au Filetype php set spell
endif
au Filetype php set textwidth=80
"Remove Umlaute
function TexTransUmlaute()
- execute ':%s/ü/\\\"u/ge'
- execute ':%s/Ü/\\\"U/&'
- execute ':%s/ö/\\\"o/&'
- execute ':%s/Ö/\\\"O/&'
- execute ':%s/ä/\\\"a/&'
- execute ':%s/Ä/\\\"A/&'
- execute ':%s/ß/\\\"s/&'
- execute ':%s/²/\^2/&'
+ execute ':%s/ü/\\\"u/ge'
+ execute ':%s/Ü/\\\"U/&'
+ execute ':%s/ö/\\\"o/&'
+ execute ':%s/Ö/\\\"O/&'
+ execute ':%s/ä/\\\"a/&'
+ execute ':%s/Ä/\\\"A/&'
+ execute ':%s/ß/\\\"s/&'
+ execute ':%s/²/\^2/&'
endfunction
function FindWordRepeatings()
- execute '/\(\<\S\+\>\)\s\+\1\>'
+ execute '/\(\<\S\+\>\)\s\+\1\>'
" let pos = search('\(\<\S\+\>\)\s\+\1\>', "cw")
" call cursor(pos)
endfunction
au Filetype tex set smartindent
if version >= 700
- au Filetype tex set spell
+ au Filetype tex set spell
endif
if filereadable($HOME . "/.vimrc-local")
- source ~/.vimrc-local
+ source ~/.vimrc-local
endif