对于喜欢vim的同学们,在写代码的时候可能遇到一些不是太方便的事情,例如创建一个文件,在正常的IDE中都会创建一个头注释,作为说明,这块在VIM也是可以实现的
"SET Comment START
autocmd BufNewFile *.php,*.js,*.cpp exec ":call SetComment()" |normal 10Go
func SetComment()
if expand("%:e") == 'php'
call setline(1, "<?php")
elseif expand("%:e") == 'js'
call setline(1, '//JavaScript file')
elseif expand("%:e") == 'cpp'
call setline(1, '//C++ file')
endif
call append(1, '/**')
call append(2, ' * Create by YourName')
call append(3, ' * Mail: YourName@XXX.com')
call append(4, ' * Date: '.strftime("%Y-%m-%d"))
call append(5, ' * Time: '.strftime("%H:%M:%S"))
call append(6, ' */')
" call append(7, '')
endfunc
在创建文件的时候支持三种类型,分别是php,js,cpp这三类,如果有需要可以自己行扩展.
下图是我配置后创建了一个php文件的一个效果图