using a VIM script, using a template, a few lines of code can be implemented very useful.
code in the ~/.VIMRC
"Auto Add Pyhton header--startautocmd bufnewfile *.py 0r ~/.vim/vim_template/vim_pyhton_headerautocmd BufNewFile *.py ks |call FileName () | ' Sautocmd bufnewfile *.py ks|call createdtime () | ' Sfun FileName () If line ("$") > 10let L = Ten "Here is the letter L is not the number 1 elselet l = line (" $ ") endif EXE" 1, ". "G/file name:.*/s/file name:.*/file Name:". Expand ("%") "The first is the number 1, here's the File Name: to be consistent with the template Endfun Fun createdtime () if Line ("$") > 10let L = 10elselet L = line ("$") endif EXE "1,". L. "G/created time:.*/s/created time:.*/created Time:". Strftime ("%y-%m-%d%T") "Create time here: to be consistent with the template Endfun" auto Add Python header--end
The template code file is~/.vim/vim_template/vim_pyhton_header
#!/usr/bin/python#-*-coding:utf-8-*-############################ #File Name: #Author: orangleliu#mail: [Email Protected] #Created time:############################
Description 1 template paths to be consistent2 Don't forget to keep. VIMRC in the Replace tag name and template in the same example Create time:
Test results
[Email protected]:~$ vim c.py[email protected]:~$ cat c.py #!/usr/bin/python#-*-coding:utf-8-*-###################### ###### #File name:c.py#author:orangleliu#mail: [email protected] #Created time:2014-12-11 20:16:33################### #########
Other languages can also be programmed similarly, so that you don't have to write all kinds of header files at the beginning of the code, the Protocol, the author, and the date.
Reference: https://gist.github.com/zxkletters/6521114
This article is from the "Orangleliu Notebook" blog, reproduced please be sure to keep this source http://blog.csdn.net/orangleliu/article/details/41902851
Author Orangleliu using Attribution-NonCommercial-sharing protocol in the same way
[Vim] New Python file automatically add Python header