[svc][op]vim自动添加注释

时间:2022-01-02 17:15:42

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

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

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

3,兴趣需要培养

一 添加vim头部信息.

[svc][op]vim自动添加注释

系统:C67

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

map <F4> :call TitleDet()<cr>'s
function AddTitle()
call append(,"/*=============================================================================")
call append(,"#")
call append(,"# Author: lanny - ihorse@foxmail.com")
call append(,"#")
call append(,"# QQ : 781647046")
call append(,"#")
call append(,"# Last modified: ".strftime("%Y-%m-%d %H:%M"))
call append(,"#")
call append(,"# Filename: ".expand("%:t"))
call append(,"#")
call append(,"# Description: ")
call append(,"#")
call append(,"=============================================================================*/")
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=
while n <
let line = getline(n)
if line =~ '^\#\s*\S*Last\smodified:\S*.*$'
call UpdateTitle()
return
endif
let n = n +
endwhile
call AddTitle()
endfunction