X-Git-Url: https://git.sthu.org/?p=vimconf.git;a=blobdiff_plain;f=macros.vim;h=d74406055ece5b04f6c1184bcbfe2f7c9340adfd;hp=b0c94ddefdd6a4057ee88caf5bb2bd0b8fbfb884;hb=54e19f594a9e8d780f4b84a4a2ee4800484403c1;hpb=e88f3b103ccfad5854f4c5c7e64df998e02c4da9 diff --git a/macros.vim b/macros.vim index b0c94dd..d744060 100644 --- a/macros.vim +++ b/macros.vim @@ -10,6 +10,11 @@ function TexTransUmlaute() execute ':%s/²/\^2/&' endfunction +function! s:texTableBfEntries() + execute 's/\( *\)\([^ &][^&]*[^ &]\)\( \+\)/\1\\textbf{\2}\3/g' +endfunction + +command! -range TexTableBfEntries call s:texTableBfEntries() "Open current file with a specific program function OpenIn(prog) @@ -73,9 +78,12 @@ endfunction function InsertIncludeGuardsWithoutEndif() - let gatename = substitute(expand("%:t"), "\\.", "_", "g") . '_' . strpart(system('pwgen -c 16 1'), 0, 16) - execute "normal! i#ifndef " . gatename - execute "normal! o#define " . gatename + " Build name of guard: Take filename, replace some chars by _ and + " prepend a random sequence to make guard robust against file name + " collisions. + let guardname = substitute(expand("%:t"), "[\\.-]", "_", "g") . '_' . strpart(system('pwgen -c 16 1'), 0, 16) + execute "normal! i#ifndef " . guardname + execute "normal! o#define " . guardname endfunction