溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

為vim編譯默認作者信息

發(fā)布時間:2020-07-12 20:34:41 來源:網(wǎng)絡 閱讀:217 作者:hanye韓也 欄目:系統(tǒng)運維
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 實現(xiàn)一鍵插入編輯信息
向AI問一下細節(jié)

免責聲明:本站發(fā)布的內容(圖片、視頻和文字)以原創(chuàng)、轉載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關證據(jù),一經查實,將立刻刪除涉嫌侵權內容。

AI