Skip to content

Instantly share code, notes, and snippets.

@Osse
Created August 11, 2012 12:46
Show Gist options
  • Save Osse/3324231 to your computer and use it in GitHub Desktop.
Save Osse/3324231 to your computer and use it in GitHub Desktop.
Insert_header_guards()
let header = ['#ifndef ', '# define ', '#endif ' ]
function! Insert_header_guards()
let basename=substitute(@%, "[^/]*/", "", "g")
let underscored=tr(basename, ".", "_")
let const=substitute(underscored, ".*", "\\U\\0", "")."_"
call setline(1, map(g:header, 'v:val . const'))
call append('$', ['','','','#endif ' . const])
5
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment