标签:
今天初步学习了下vim的脚本知识,并尝试写了一个简单的脚本。当然,这个脚本很简单,使用的方法也很笨拙。不过,这仅仅是一个开始,等以后随着对vim语法的深入了解,会不断优化这个脚本的。先记录下来
" annotation.vim " Version: 1.0 if exists("g:zsl_loaded_annotation") || &cp || v:version < 700 finish endif let g:zsl_loaded_annotation = 1 "for java & C/C++ function AnnotationJ() call AnnotationBase("/*", "*/") endfunction "for perl function AnnotationP() call AnnotationBase("\#") endfunction "for shell function AnnotationS() call AnnotationBase(‘"‘) endfunction "for xml function AnnotationX() call AnnotationBase("\< --", "!--\>") endfunction "基础函数 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", ‘‘)) +1 endfunction
标签:
原文地址:http://www.cnblogs.com/zhangshuli-1989/p/zsl_2016_03_31_0009.html