1 " Tranlate umlauts to tex-syntax umlauts
2 function TexTransUmlaute()
3 execute ':%s/ü/\\\"u/ge'
4 execute ':%s/Ü/\\\"U/&'
5 execute ':%s/ö/\\\"o/&'
6 execute ':%s/Ö/\\\"O/&'
7 execute ':%s/ä/\\\"a/&'
8 execute ':%s/Ä/\\\"A/&'
9 execute ':%s/ß/\\\"s/&'
14 "Open current file with a specific program
16 silent execute ":!" . a:prog . " % &"
20 "Prepend the namespace to an identifier, e.g. 'std::' before 'map' excluding
21 "those in C/C++ comments.
22 function PrependCppNamespaceToIdent(ns, id)
24 " To match Not to match
28 "|/* */ /* */ id |/* */ // id
36 " In order to not match '* id' it is assumed that multi-line comment lines
37 " in the middle begin with a star.
39 " If #include and // and /* and ^* and :: is not prepend:
40 execute ':%s@\(\(#include\|\/\/\|\/\*\|^\s*\*[^/]\).*\|::\)\@<!\<' . a:id . '\>@' . a:ns . '::' . a:id . '@ge'
41 " If #include and // and :: is not prepend, but */ is, and no further /* or // are found
42 execute ':%s@\(\(#include\|\/\/\).*\)\@<!\*\/\(\/[^\/\*]\|[^\/]\)*\zs\(::\)\@<!\<' . a:id . '\>@' . a:ns . '::' . a:id . '@ge'
47 "Prepend STL namespace 'std::' to several identifiers
48 function PrependSTLNamespace()
49 " This list of identifier is not complete, but adding all of them is too
50 " much. We rather like to add identifieres that are 'typical' for C++.
51 " Others, like 'move' are likely to not be C++ specific. In this cases the
52 " user is asked to call PrependCppNamespaceToIdent by hand.
54 let id = id +['cin', 'cout', 'cerr', 'endl']
55 let id = id +['swap', 'sort', 'max', 'min']
56 let id = id +['vector', 'deque', 'list', 'map', 'multimap', 'set']
57 let id = id +['queue', 'stack', 'priority_queue']
58 let id = id +['ostream', 'istream', 'sstream']
59 let id = id +['pair', 'string']
62 call PrependCppNamespaceToIdent("std", i)
67 function EscapeHexToChar()
68 echo 'Call "x/Nxb addr" in GDB to print N bytes at addr'
70 execute '%s/\s*0x\(\x\x\)/\\x\1/g'
71 execute '%s/^\(.*\)$/"\1"/'
75 function InsertIncludeGuardsWithoutEndif()
76 let gatename = substitute(expand("%:t"), "\\.", "_", "g") . '_' . strpart(system('pwgen -c 16 1'), 0, 16)
77 execute "normal! i#ifndef " . gatename
78 execute "normal! o#define " . gatename
82 function AddIncludeGuards()
83 execute "normal! Go#endif"
85 call InsertIncludeGuardsWithoutEndif()
90 " If pandoc.css exists, use it
92 if findfile("pandoc.css", ".") == "pandoc.css"
93 let cssopts = "-c pandoc.css --self-contained"
96 execute ":!pandoc " . cssopts . " --toc " . @% . " -o " . @% . ".html"
100 if filereadable($HOME . '/.vim/macros-local.vim')
101 source ~/.vim/macros-local.vim