Created
September 11, 2013 09:05
-
-
Save zxkletters/6521114 to your computer and use it in GitHub Desktop.
.vimrc配置, 新建文件时,如果autocmd匹配文件类型成功,则根据模版自动生成文件头
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" auto add file header | |
autocmd BufNewFile *.py 0r /home/zxkletters/.vim/vim_template/vim_header_for_python | |
autocmd BufNewFile *.py ks|call FileName()|'s | |
autocmd BufNewFile *.py ks|call CreatedTime()|'s | |
autocmd BufNewFile *.sh 0r /home/zxkletters/.vim/vim_template/vim_header_for_sh | |
autocmd BufNewFile *.sh ks|call FileName()|'s | |
autocmd BufNewFile *.sh ks|call CreatedTime()|'s | |
fun FileName() | |
if line("$") > 10 | |
let l = 10 | |
else | |
let l = line("$") | |
endif | |
exe "1," . l . "g/File Name:.*/s/File Name:.*/File Name: " .expand("%") | |
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") | |
endfun | |
" end auto add file header |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
/home/zxkletters/.vim/vim_template/vim_header_for_python文件内容:
/home/zxkletters/.vim/vim_template/vim_header_for_sh文件内容: