安装vimplus参考
http://www.cnblogs.com/highway-9/p/5984285.html?spm=a2c4e.11153940.blogcont75530.9.39142637RWOmhw
在已经完成vimplus的安装后
在vimplus中预定义的编码脚本放在~/.vim/plugged/prepare-code/prepare/autoload
在prepare.vim中插入这个函数,参考的是下面的博文
https://blog.csdn.net/amoscykl/article/details/80616688
" 生成作者信息
function! s:gen_information(suffix)
if a:suffix == 'sh' || a:suffix == 'py'
call setline(1, "##########################################################################")
call append(line("."), "# File Name: ".expand("%"))
call append(line(".")+1, "# Author: Name")
call append(line(".")+2, "# mail: [email protected]")
call append(line(".")+3, "# Created Time: ".strftime("%c"))
call append(line(".")+4, "#########################################################################")
call append(line(".")+5, "")
elseif a:suffix == 'c' || a:suffix == 'cpp' || a:suffix == 'h'
call setline(1, "/*************************************************************************")
call append(line("."), "*File Name: ".expand("%"))
call append(line(".")+1, "*Author: Name")
call append(line(".")+2, "*[email protected]")
call append(line(".")+3, "*Created Time: ".strftime("%c"))
call append(line(".")+4, " ************************************************************************/")
call append(line(".")+5, "")
endif
endfunction
并在主函数中添加代码
function! prepare#prepare#gen_prepare_code()
let suffix = prepare#util#get_current_file_suffix()
call <sid>gen_information(suffix) "生成作者信息
call <sid>gen_prepare_code_by_suffix(suffix)
endfunction
并在util.vim中
prepare#util#write_text_at_current_row函数中
添加
execute "normal G"
function! prepare#util#write_text_at_current_row(text)
execute "normal G"
execute "normal i" . a:text
endfunction
这是新创建后的界面: