Skip to content

Commit

Permalink
added support for escaping backticks (issue#74)
Browse files Browse the repository at this point in the history
  • Loading branch information
msanders committed Dec 28, 2009
1 parent 9fe9170 commit 26e93e9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 7 additions & 5 deletions autoload/snipMate.vim
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,17 @@ endf
" Prepare snippet to be processed by s:BuildTabStops
fun s:ProcessSnippet(snip)
let snippet = a:snip
" Evaluate eval (`...`) expressions.
" Evaluate eval (`...`) expressions.
" Backquotes prefixed with a backslash are ignored.
" Using a loop here instead of a regex fixes a bug with nested "\=".
if stridx(snippet, '`') != -1
while match(snippet, '`.\{-}`') != -1
let snippet = substitute(snippet, '`.\{-}`',
\ substitute(eval(matchstr(snippet, '`\zs.\{-}\ze`')),
\ "\n\\%$", '', ''), '')
while match(snippet, '[^\\]`.\{-}[^\\]`') != -1
let snippet = substitute(snippet, '[^\\]\zs`.\{-}[^\\]`\ze',
\ substitute(eval(matchstr(snippet, '[^\\]`\zs.\{-}[^\\]\ze`')),
\ "\n\\%$", '', ''), '')
endw
let snippet = substitute(snippet, "\r", "\n", 'g')
let snippet = substitute(snippet, '\\`', '`', 'g')
endif

" Place all text after a colon in a tab stop after the tab stop
Expand Down
2 changes: 1 addition & 1 deletion syntax/snippet.vim
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
syn match snipComment '^#.*'
syn match placeHolder '\${\d\+\(:.\{-}\)\=}' contains=snipCommand
syn match tabStop '\$\d\+'
syn match snipCommand '`.\{-}`'
syn match snipCommand '[^\\]`.\{-}`'
syn match snippet '^snippet.*' transparent contains=multiSnipText,snipKeyword
syn match multiSnipText '\S\+ \zs.*' contained
syn match snipKeyword '^snippet'me=s+8 contained
Expand Down

0 comments on commit 26e93e9

Please sign in to comment.