Set a last modified value in c header notice

This commit is contained in:
Michael Campagnaro 2017-07-26 12:48:20 -04:00
parent 53b73c8d77
commit cfe99ce97b
2 changed files with 13 additions and 3 deletions

View File

@ -1,6 +1,7 @@
/*=======================================================================================
File:
Creation Date:
Last Modified:
Creator: Michael Campagnaro
Notice: (C) Copyright $year by Jelly Pixel, Inc. All Rights Reserved.
=======================================================================================*/

15
vimrc
View File

@ -318,9 +318,18 @@ augroup campoCmds
" C/C++ template
autocmd bufnewfile *.{c,cc,cpp,h,hpp} 0r ~/.vim/templates/c_header_notice
autocmd bufnewfile *.{c,cc,cpp,h,hpp} exe "2," . 6 . "g/File:.*/s//File: " .expand("%")
autocmd bufnewfile *.{c,cc,cpp,h,hpp} exe "2," . 6 . "g/Creation Date:.*/s//Creation Date: " .strftime("%Y-%m-%d")
autocmd bufnewfile *.{c,cc,cpp,h,hpp} exe "2," . 6 . "g/$year/s//" .strftime("%Y")
autocmd bufnewfile *.{c,cc,cpp,h,hpp} exe "2," . 7 . "g/File:.*/s//File: " .expand("%")
autocmd bufnewfile *.{c,cc,cpp,h,hpp} exe "2," . 7 . "g/Creation Date:.*/s//Creation Date: " .strftime("%Y-%m-%d")
autocmd bufnewfile *.{c,cc,cpp,h,hpp} exe "2," . 7 . "g/$year/s//" .strftime("%Y")
function! s:InsertModifiedDateIfRequired()
if &modified
normal! m0
execute "2," . 7 . "g/Last Modified:.*/s//Last Modified: " .strftime("%Y-%m-%d %T")
normal! '0
endif
endfunction
autocmd Bufwritepre,filewritepre *.{c,cc,cpp,h,hpp} call <SID>InsertModifiedDateIfRequired()
function! s:InsertHeaderGates()
let gatename = substitute(toupper(expand("%:t")), "\\.", "_", "g")
execute "normal! ggO#ifndef " . gatename