总所周知,vim的功能十分强大。在上家公司,深有体会,当时直接拷了大佬的vim插件,放到自己服务器上,用着很爽,但是当时也没有过多关注都有哪些插件,换东家时挥一挥衣袖直接走人,现在服务上的基础配置需要自己从零搞起,其他还好,vim用着尤其掣肘。网上查了很多资料,慢慢丰富自己的vim。今天记录下添加头部信息,因为常用的时php和js,所有只对这两类文件做了定制化
"################### set file head #########################
"autocmd创建新文件自动调用setfilehead()函数
autocmd BufNewFile *.js,*.php exec ":call Setfilehead()"
func Setfilehead()
if expand("%:e") == 'php'
call setline(1, "<?php")
elseif expand("%:e") == 'js'
call setline(1, '//JavaScipt file')
elseif expand("%:e") == 'cpp'
call setline(1, '//c++ file')
endif
call append(1, '/***********************************************')
call append(2, '#')
call append(3, '# Filename: '.expand("%"))
call append(4, '#')
call append(5, '# Author: liuwenyan@zuoyebang.com')
call append(6, '# Description: ---')
call append(7, '# Create: '.strftime("%Y-%m-%d %H:%M:%S"))
call append(8, '# Last Modified: '.strftime("%Y-%m-%d %H:%M:%S"))
call append(9, '***********************************************/')
call append(10, '')
endfunc