How I am suppose to use the the snip() function contained in the imaps.vim plugin in the latex package described below:
Snip: puts a scissor string above and below block of text {{{
Description:
this puts a the string “——–%<———” above and below the visually
selected block of lines. the length of the ‘tearoff’ string depends on the
maximum string length in the selected range. this is an aesthetically more
pleasing alternative instead of hard-coding a length.
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
Refer to the line immediately after the
Snip()definition inimaps.vim:This defines the command
Snip, which can be invoked on any range. In visual mode, vim automatically inserts the range'<,'>when you enter a command, so typing:and thenSnip, which results in:'<,'>Snip, will call the function on the current selection.Note that you can also manually specify ranges. For example,
:1,5 Snipwill snip lines 1 through 5,:'m,'n Snipwill snip from markmto markn, and:Snipwill apply only to the current line.In order to avoid having to type
:Snipevery time, you can map this command to a key of your choice. For example, you can mapzin visual mode to callSnipon the current selection as follows: