- su root
- vim /etc/vimrc
先声明不同有不同注释的,如shell,perl,python等,然后声明具有相同注释的,如Verilog,systemverilog,c,c++,makefile等。
不同部分的声明
func SetTitle()
if &filetype == 'sh'
call setline(1, "/#!/bin/bash")
call setline(2, "/# ")
call setline(3, "/# Author: XXX@163.com")
call setline(4, "/# ")
call setline(5, "/# Created Time: ".strftime("%c"))
call setline(6, "/# ")
call setline(7, "/# FileName: ".expand("%"))
call setline(8, "/# ")
call setline(9, "/# Description: ")
call setline(10, "/# ")
call setline(11, "/# ChangeLog:")
elseif &filetype == 'python'
call setline(1, "/#!env python")
call setline(2, "/#coding=utf-8")
call setline(3, "/# ")
call setline(4, "/# Author: XXX@163.com")
call setline(5, "/# ")
call setline(6, "/# Created Time: ".strftime("%c"))
call setline(7, "/# ")
call setline(8, "/# FileName: ".expand("%"))
call setline(9, "/# ")
call setline(10, "/# Description: ")
call setline(11, "/# ")
call setline(12, "/# ChangeLog:")
elseif &filetype == 'perl'
call setline(1, "/#!env perl")
call setline(2, "/#")
call setline(3, "/# ")
call setline(4, "/# Author: XXX@163.com")
call setline(5, "/# ")
call setline(6, "/# Created Time: ".strftime("%c"))
call setline(7, "/# ")
call setline(8, "/# FileName: ".expand("%"))
call setline(9, "/# ")
call setline(10, "/# Description: ")
call setline(11, "/# ")
call setline(12, "/# ChangeLog")
endif
endfunc
autocmd BufNewFile *.php,*.pl,*.py,*.[ch],*.py,*.sh,*.java exec ":call SetTitle()"
相同部分的声明
autocmd BufNewFile *.[ch],*.hpp,*.cpp,makefile,*.mk,*.sh exec ":call SetComment()"
" 加入注释
func SetComment()
call setline(1,"/*================================================================")
call append(line("."), "* Copyright (C) ".strftime("%Y")." Sangfor Ltd. All rights reserved.")
call append(line(".")+1, "* ")
call append(line(".")+2, "* Filename :".expand("%:t"))
call append(line(".")+3, "* Author :LuZhenrong")
call append(line(".")+4, "* Created Time:".strftime("%Y.%m.%d"))
call append(line(".")+5, "* Description:")
call append(line(".")+6, "*")
call append(line(".")+7, "================================================================*/")
call append(line(".")+8, "")
call append(line(".")+9, "")
endfunc