码迷,mamicode.com
首页 > 系统相关 > 详细

新建vim脚本自动添加作者信息(脚本)

时间:2015-12-11 16:49:14      阅读:214      评论:0      收藏:0      [点我收藏+]

标签:return   新建   normal   信息   

新建vim脚本自动添加作者信息(脚本)

vim /etc/vimrc

####################尾部添加以下代码###############################


map <F4> ms:call AddAuthor()<cr>‘s
function AddAuthor()

        let n=1

        while n < 5

                let line = getline(n)

                if line =~‘^\s*\*\s*\S*Last\s*modified\s*:\s*\S*.*$‘

                        call UpdateTitle()

                        return

                endif

                let n = n + 1

        endwhile

        call AddTitle()

endfunction

function UpdateTitle()

        normal m‘

        execute ‘/* Last modified\s*:/s@:.*$@\=strftime(": %Y-%m-%d %H:%M")@‘

        normal "

        normal mk

        execute ‘/* Filename\s*:/s@:.*$@\=": ".expand("%:t")@‘

        execute "noh"

        normal ‘k

        echohl WarningMsg | echo "Successful in updating the copy right." | echohl None

endfunction


n AddTitle()

        call append(0,"/**********************************************************")

        call append(1," * Author        : ")

        call append(2," * Email         : ")

        call append(3," * Last modified : ".strftime("%Y-%m-%d %H:%M"))

        call append(4," * Filename      : ".expand("%:t"))

        call append(5," * Description   : ")

        call append(6," * *******************************************************/")

        echohl WarningMsg | echo "Successful in adding the copyright." | echohl None

endfunction

新建vim脚本自动添加作者信息(脚本)

标签:return   新建   normal   信息   

原文地址:http://jiarh.blog.51cto.com/3467177/1721975

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!