Today, I studied the scripting knowledge of vim and tried to write a simple script. Of course, the script is simple and the method used is clumsy. However, this is only the beginning, and later with a deep understanding of the VIM syntax, will continue to optimize the script. Record them first.
"Annotation.vim"version:1.0ifExists ("G:zsl_loaded_annotation") | | &CP | | V:version < 700Finishendiflet g:zsl_loaded_annotation= 1 "For Java & c/c++function Annotationj () Call Annotationbase ("/*", "*/") Endfunction" forPerlfunctionAnnotationp () Call Annotationbase ("\#") Endfunction"For shellfunction AnnotationS () Call Annotationbase ('"‘) endfunction "for Xmlfunction Annotationx () Call Annotationbase (" \<--","!--\> ") endfunction" basic functions function Annotationbase (...) Let time = ' 2016-01-01 ' Let Anno = ' modify by zhangshui time begin ' Let CurLine = Line (".") echo a:1 If a:0 = = 1 Let anno = a:1. " ". Anno ElseIf a:0 = = 2 Let Anno = a:1." ". Anno." ". A:2 endif if exists (" *strftime ") Let time = Strftime ("%y-%m-%d ") endif Let Anno = Substitute (anno," Time ", Time, ‘‘Call append (CurLine, anno) call append (curline+1, Substitute (anno, "Begin", "End",‘‘)) +1endfunction
Quick notes for VIM scripts