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

vim自动添加注释

时间:2016-05-04 13:27:08      阅读:478      评论:0      收藏:0      [点我收藏+]

标签:

我想了下,要做好一件事,

1,首先喜欢它最才有动机去了解它

2,道听途说about那东西的,会去了解并去玩转

3,兴趣需要培养

 

一 添加vim头部信息.

技术分享

系统:C67

追加以下代码到 /etc/vimrc里即可.

map <F4> :call TitleDet()<cr>s
function AddTitle()
    call append(0,"/*=============================================================================")
    call append(1,"#")
    call append(2,"# Author: lanny - ihorse@foxmail.com")
    call append(3,"#")
    call append(4,"# QQ : 781647046")
    call append(5,"#")
    call append(6,"# Last modified: ".strftime("%Y-%m-%d %H:%M"))
    call append(7,"#")
    call append(8,"# Filename: ".expand("%:t"))
    call append(9,"#")
    call append(10,"# Description: ")
    call append(11,"#")
    call append(12,"=============================================================================*/")
    echohl WarningMsg | echo "Successful in adding the copyright." | echohl None
endf

function UpdateTitle()
    normal m    execute /# *Last modified:/s@:.*$@\=strftime(":\t%Y-%m-%d %H:%M")@
    normal ‘‘
    normal mk
    execute /# *Filename:/s@:.*$@\=":\t\t".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 < 10
        let line = getline(n)
        if line =~ ^\#\s*\S*Last\smodified:\S*.*$
            call UpdateTitle()
            return
        endif
        let n = n + 1
    endwhile
    call AddTitle()
endfunction

vim自动添加注释

标签:

原文地址:http://www.cnblogs.com/iiiiher/p/5458004.html

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