温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

为vim编译默认作者信息

发布时间:2020-07-12 20:34:41 来源:网络 阅读:220 作者:hanye韩也 栏目:系统运维
vim /etc/vim/vimrc
map <F4> ms:call TitleDet()<cr>'s
function AddTitle()
    call append(0,"#!/bin/bash")
    call append(1,"##############################################")
    call append(2,"#Author: hanye")
    call append(3,"#Email:  hz7726@163.com")
    call append(4,"#Last modified: ".strftime("%Y/%m/%d/%H:%M"))
    call append(5,"#Filename: ".expand("%:t"))
    call append(6,"#Revision:  0.1")
    call append(7,"#Description: ")
    call append(8,"#crontab: * * * * * ".expand("%:t"))
    call append(9,"#Website:   www.hanye")
    call append(10,"#License: GPL")
    call append(11,"##############################################")
    echohl WarningMsg | echo "Successful in adding the copyright." | echohl None
endfunction
function UpdateTitle()
    normal m'
    execute '/#*Last modified:/s@:.*$@\=strftime(":%Y-%m-%d %H:%M")@'
    normal ''
    normal mk
    execute '/#*Filename:/s@:.*$@\=":".expand("%:t")@'
    execute "noh"
    normal 'k
    echohl WarningMsg | echo "Successful in updating the copy right." | echohl None
endfunction
function TitleDet()
    let n=1
    while n < 7
        let line = getline(n)
        if line =~ '^\#\s*\S*Last\smodified:\S*.*$'
            call UpdateTitle()
            return
        endif
        let n = n + 1
    endwhile
    call AddTitle()
endfunction
测试 vim a.txt
 fn + f4/f4 实现一键插入编辑信息
向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI