Created
August 17, 2014 16:13
-
-
Save posva/1ece81bf7127ab3e257c to your computer and use it in GitHub Desktop.
Use Ctr+H to add the classic header with defines guards for C/C++ files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" fill rest of line with characters | |
function! FillLine( str, l ) | |
" strip trailing spaces first | |
.s/[[:space:]]*$// | |
" calculate total number of 'str's to insert | |
let reps = (a:l - col("$")) / len(a:str) | |
" insert them, if there's room, removing | |
" trailing spaces (though forcing | |
" there to be one) | |
if reps > 0 | |
.s/$/\=(repeat(a:str, reps))/ | |
endif | |
endfunction | |
let name = 'Eduardo San Martin Morote' | |
let email = '[email protected]' | |
let web = 'http://posva.net' | |
map <buffer> <C-H> <ESC>ggO/**<ESC>:call FillLine("*", 81)<CR>A<CR> <C-R>=expand("%:t:r")<CR><ESC>:call FillLine(" ", 80)<CR>A*<CR><C-R>=strftime("%a %b %d %Z %Y")<CR><ESC>:call FillLine(" ", 80)<CR>A*<CR>Copyright <C-R>=name<CR><ESC>:call FillLine(" ", 80)<CR>A*<CR><C-R>=email<CR><ESC>:call FillLine(" ", 80)<CR>A*<CR><C-R>=web<CR><ESC>:call FillLine(" ", 80)<CR>A*<CR><ESC>:call FillLine("*", 80)<CR>A/<CR><ESC>ggO#ifndef __<C-R>=expand("%:t:r")<CR>_H__<ESC>^f gUg_o#define __<C-R>=expand("%:t:r")<CR>_H__<ESC>^f gUg_Go#endif<ESC>kko |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment