I wrote a simple python template in ~/.vim/template/pythontmp.txt,
and use
$> autocmd bufnewfile *.py :0r ~/.vim/template/pythontmp.txt
to load the template when i create a new python script.
The problem i开发者_开发问答s that i'd like to add creation time to the comment of the document.
How can I do this? Thanks!
You can use strftime function for this:
if exists('*strftime')
au BufNewFile *.py :call append(0, '# Created: '.strftime('%a, %d %b %Y %T %z'))
endif
According to the documentation, strftime
is not present on some systems. See man strftime
(if you are on *nix) for details of format.
精彩评论