漂亮男人2017-05-16 16:42:17
不需要插件,配置下就行了,如这篇文章(配置vim在源代码中自动添加作者信息)
要创建文件自动添加的话可以先把默认文件保存在一个文件里,然后在.vimrc
里加入类似如下代码:
au BufNewFile *.xml 0r ~/.vim/xml.skel | let IndentStyle = "xml"
au BufNewFile *.html 0r ~/.vim/html.skel | let IndentStyle = "html"
插件的话试试这个页面上列出来的。
Source
为情所困2017-05-16 16:42:17
function MyCopy(type, position)
if a:position == 'start'
let line_num = line(".")
else
let line_num = a:position
endif
if a:type == "class"
call setline(line_num,"/**")
call append(line_num+0," * $RCSfile$ ".expand("%"))
call append(line_num+1," * @touch date ".strftime("%c"))
call append(line_num+2," * @author Rambo Lee <blabalbal#babab>")
call append(line_num+3," * @package ")
call append(line_num+4," * @link http://lanbolee.com/")
call append(line_num+5," * @Copyright © ".strftime("%Y")." All rights reserved.")
call append(line_num+6," * @license http://www.zend.com/license/3_0.txt PHP License 3.0")
call append(line_num+7," * @version $Id$ ")
call append(line_num+8," * @filesource ")
call append(line_num+9," */")
else
if a:type == "func"
call setline(line_num," /**")
call append(line_num+0," * @access ")
call append(line_num+1," * @author Rambo Lee <blabalbal#babab>")
call append(line_num+2," * @param")
call append(line_num+3," * @return")
call append(line_num+4," */")
else
call setline(line_num," /**")
call append(line_num+0," * @access ")
call append(line_num+1," * @var ")
call append(line_num+2," */")
endif
endif
endfunction
map <C-I> <Esc>:call MyCopy("class",'start')<CR><Esc>10j$a
map df <Esc>:call MyCopy("func", 'start')<CR><Esc>
map dv <Esc>:call MyCopy("var", 'start')<CR><Esc>
share 一下 .vimrc 我是看别人这么实现的,然后自己微创新了一下。