let s:sigil = nr2char(31) let snipmate#legacy#sigil = s:sigil " Prepare snippet to be processed by s:BuildTabStops function! snipmate#legacy#process_snippet(snip) abort let snippet = a:snip let esc_bslash = '\%(\\\@ a:lnum \ ? len(matchstr(beforeMark, '.*\n\zs.*')) \ : a:col + len(beforeMark)) call add(stops[i].mirrors, { 'line' : line, 'col' : col }) let withoutOthers = substitute(withoutOthers, ''.s:sigil .''.i.'\ze\(\D\|$\)', '', '') endw endif let i += 1 endw let stops[i] = stops[0] return [stops, i + 1] endfunction function! s:substitute_visual(snippet, visual) abort let lines = [] for line in split(a:snippet, "\n") let indent = matchstr(line, '^\t\+') call add(lines, substitute(line, '{VISUAL}', \ substitute(escape(a:visual, '%\'), "\n", "\n" . indent, 'g'), 'g')) endfor return join(lines, "\n") endfunction " Counts occurences of haystack in needle function! s:count(haystack, needle) abort let counter = 0 let index = stridx(a:haystack, a:needle) while index != -1 let index = stridx(a:haystack, a:needle, index+1) let counter += 1 endw return counter endfunction