vim脚本环境配置vimrc
vimrc可以放在两个地方,第一个就是用户家目录下(如/root/.vimrc),只是当前用户环境下生效
第二个是在/etc/vimrc,全局配置,所有用户都生效
autocmd BufNewFile *.sh,*.py exec ":call SetTitle()"
let $author_name = "xunyin"
let $author_email = "lnhxzwb@126.com"
func SetTitle()
if &filetype == 'sh'
call setline(1,"\###################################################################")
call append(line("."), "\# File Name: ".expand("%"))
call append(line(".")+1, "\# Author: ".$author_name )
call append(line(".")+2, "\# E-mail: ".$author_email)
call append(line(".")+3, "\# Created Time: ".strftime("%c"))
call append(line(".")+4, "\#==================================================================")
call append(line(".")+5, "\#!/bin/bash")
call append(line(".")+6, "")
elseif &filetype == 'python'
call setline(1,"\###################################################################")
call append(line("."), "\# File Name: ".expand("%"))
call append(line(".")+1, "\# Author: ".$author_name)
call append(line(".")+2, "\# mail: ".$author_email)
call append(line(".")+3, "\# Created Time: ".strftime("%c"))
call append(line(".")+4, "\#=============================================================")
call append(line(".")+5, "\#!/usr/bin/python")
call append(line(".")+6, "")
endif
endfunc
autocmd BufNewfile * normal G #跳到最后一行
温馨提示:如无特殊说明,本站文章均为作者原创,转载请注明出处!


