"auto add pyhton header --start autocmd BufNewFile *.py 0r ~/.vim/vim_template/vim_pyhton_header autocmd BufNewFile *.py ks|call FileName()|'s autocmd BufNewFile *.py ks|call CreatedTime()|'s fun FileName() if line("$") > 10 let l = 10 "这里是字母L 不是数字1 else let l = line("$") endif exe "1," . l . "g/File Name:.*/s/File Name:.*/File Name: " .expand("%") "最前面是数字1,这里的File Name: 要和模板中一致 endfun fun CreatedTime() if line("$") > 10 let l = 10 else let l = line("$") endif exe "1," . l . "g/Created Time:.*/s/Created Time:.*/Created Time: " .strftime("%Y-%m-%d %T") "这里Create Time: 要和模板中一致 endfun "auto add python header --end
#!/usr/bin/python #-*- coding:utf-8 -*- ############################ #File Name: #Author: orangleliu #Mail: orangleliu@gmail.com #Created Time: ############################
lzz@ubuntu:~$ vim c.py lzz@ubuntu:~$ cat c.py #!/usr/bin/python #-*- coding:utf-8 -*- ############################ #File Name: c.py #Author: orangleliu #Mail: orangleliu@gmail.com #Created Time: 2014-12-11 20:16:33 ############################
本文出自 “orangleliu笔记本” 博客,转载请务必保留此出处http://blog.csdn.net/orangleliu/article/details/41902851
作者orangleliu 采用署名-非商业性使用-相同方式共享协议
[Vim]新建python文件自动添加python header
原文地址:http://blog.csdn.net/orangleliu/article/details/41902851