搜索

首页  >  问答  >  正文

求一个自动添加文件头的vim插件名字(有图)

如图所示,使用vim打开新文件(如a.cpp)时,自动添加文件头。想问一下哪个插件能做到这个。谢谢。

大家讲道理大家讲道理2747 天前876

全部回复(3)我来回复

  • 曾经蜡笔没有小新

    曾经蜡笔没有小新2017-05-16 16:42:17

    c.vim

    回复
    0
  • 漂亮男人

    漂亮男人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

    回复
    0
  • 为情所困

    为情所困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 我是看别人这么实现的,然后自己微创新了一下。

    回复
    0
  • 取消回复