X-Git-Url: https://git.sthu.org/?p=shutils.git;a=blobdiff_plain;f=dotfiles%2Fvim%2F.vimrc;h=5da54996af79d7730b9e6dfb1fec05781fb8b839;hp=a68602e9d83d09117f284bd94698d742a1ef8110;hb=ba8d944658a4e8b99d9c5e4762da74ca5475d213;hpb=3ac17777f987e1c78ea411f149e450015da3dfc4 diff --git a/dotfiles/vim/.vimrc b/dotfiles/vim/.vimrc index a68602e..5da5499 100644 --- a/dotfiles/vim/.vimrc +++ b/dotfiles/vim/.vimrc @@ -168,6 +168,19 @@ function EscapeHexToChar() execute '%s/^\(.*\)$/"\1"/' 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 +endfunction + +function AddIncludeGuards() + execute "normal! Go#endif" + execute "normal! gg" + call InsertIncludeGuardsWithoutEndif() +endfunction + +autocmd BufNewFile *.{h,hpp} call AddIncludeGuards() """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""