vim脚本自动添加标题注释

社会主义新天地 提交于 2019-11-27 05:03:44

一、李导版本

autocmd BufNewFile *.py,*.cc,*.sh,*.java exec ":call SetTitle()"

func SetTitle()

    if expand("%:e") == 'sh'  
        call setline(1, "#!/bin/bash")
        call setline(2, "##############################################################")  
        call setline(3, "# File Name: ".expand("%"))
        call setline(4, "# Version: V1.0")
        call setline(5, "# Author: oldboy")
        call setline(6, "# Organization: www.oldboyedu.com")
        call setline(7, "##############################################################")
    endif  
endfunc 二、51cto版本https://blog.51cto.com/thedream/1873060三、自己autocmd BufNewFile *.sh,*.script exec ":call XYY()" 72 function XYY() 73          call append(0,"#!/bin/bash                      ") 74          call append(1,"#Author:  zjz                    ") 75          call append(2,"#Create_Time:".strftime("%Y-%m-%d" )) 76          call append(3,"#Version:v1.o                    ") 77          call append(4,"#Mail:1570649754@qq.com          ") 78          call append(5,"#Description:useradd             ") 79 endfunction
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!