1

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".

  • 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 1 at 12:07
1

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
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.