开发者

add creation/modified time to python template in vim script

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜