Last active
February 7, 2020 02:54
-
-
Save yt-siden/81b31e9e02bf82d6548e to your computer and use it in GitHub Desktop.
Insert UUID-based include guard macro on VIM
This file contains 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
" C/C++ insert UUID based include guard | |
function! s:insert_include_guard() | |
let s:uuid=system('uuidgen') | |
let s:uuid=strpart(s:uuid, 0, strlen(s:uuid)-1) | |
let s:uuid=substitute(s:uuid, '[a-f]', '\u\0', 'g') | |
let s:uuid=substitute(s:uuid, '\-', '_', 'g') | |
let s:uuid='UUID_'.s:uuid | |
call append(0, '#ifndef '.s:uuid) | |
call append(1, '#define '.s:uuid) | |
call append('$', '#endif //'.s:uuid) | |
endfunction | |
command! -nargs=0 InsertIncludeGuard call s:insert_include_guard() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment