2

I have a snippet for C-like languages that looks like this:

snippet { "braces"
{
    $0
}
endsnippet

I would like to restrict this snippet to expand only if the tab trigger occurs at the end of the line.

I tried to use a regex trigger instead ({$) without success. To quote the documentation: "The snippet is expanded if the recently typed characters match the regular expression".

xsot
  • 141
  • 4
  • A regex snippet will not work because "The snippet is expanded if the recently typed characters match the regular expression." So it will always match /{$/ even if it's in the middle of the line... – filbranden May 01 '20 at 12:07

1 Answers1

2

Nevermind, I figured out how to implement it as a custom context snippet:

snippet { "braces" "snip.column == len(snip.buffer[snip.line]) - 1" e
{
    $0
}
endsnippet
xsot
  • 141
  • 4