我想如何使用下面描述的乳胶包中的 imaps.vim 插件中包含的 snip() 函数:
Snip:在文本块 {{{ 描述:
这会在视觉选择的行块的上方和下方放置一个字符串“--------%<---------”。'tearoff' 字符串的长度取决于所选范围内的最大字符串长度。这是一个更美观的替代方案,而不是硬编码长度。
function! <SID>Snip() range
let i = a:firstline
let maxlen = -2
" find out the maximum virtual length of each line.
while i <= a:lastline
exe i
let length = virtcol('$')
let maxlen = (length > maxlen ? length : maxlen)
let i = i + 1
endwhile
let maxlen = (maxlen > &tw && &tw != 0 ? &tw : maxlen)
let half = maxlen/2
exe a:lastline
" put a string below
exe "norm! o\<esc>".(half - 1)."a-\<esc>A%<\<esc>".(half - 1)."a-"
" and above. its necessary to put the string below the block of lines
" first because that way the first line number doesnt change...
exe a:firstline
exe "norm! O\<esc>".(half - 1)."a-\<esc>A%<\<esc>".(half - 1)."a-"
endfuntion