搜尋

首頁  >  問答  >  主體

求一個自動加入文件頭的vim插件名字(有圖)

如圖所示,使用vim開啟新檔案(如a.cpp)時,自動新增檔案頭。想問一下哪個插件能做到這個。謝謝。

#
大家讲道理大家讲道理2877 天前995

全部回覆(3)我來回復

  • 曾经蜡笔没有小新

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

    c.vim

    回覆
    0
  • 漂亮男人

    漂亮男人2017-05-16 16:42:17

    不需要插件,配置下就行了,如這篇文章(配置vim在源代碼中自動添加作者資訊)
    要建立檔案自動加入的話可以先把預設檔儲存在一個檔案裡,然後在.vimrc裡加入類似如下程式碼:

    1

    2

    3

    <code>au BufNewFile *.xml 0r ~/.vim/xml.skel | let IndentStyle = "xml"

    au BufNewFile *.html 0r ~/.vim/html.skel | let IndentStyle = "html"

    </code>

    插件的話試試看這個頁面上列出來的。


    Source

    回覆
    0
  • 为情所困

    为情所困2017-05-16 16:42:17

    1

    2

    3

    4

    5

    6

    7

    8

    9

    10

    11

    12

    13

    14

    15

    16

    17

    18

    19

    20

    21

    22

    23

    24

    25

    26

    27

    28

    29

    30

    31

    32

    33

    34

    35

    36

    37

    38

    39

    <code>    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>

    </code>

    share 一下 .vimrc 我是看別人這麼實現的,然後自己微創新了一下。

    回覆
    0
  • 取消回覆