2

The question may be also phrased as, can Ultisnips regular expression match after the current cursor?

My goal is to have a postfix of curly bracket for LaTeX subscripts. Say I want to type a_{bcd}, but in the first place I typed a_c. I wish I could move my cursor in the following position (cursor represented by |) a_|c, and insert a curly bracket. In the end what I get is a_{$1c$2}$0.

What appears intuitive for me is the following

snippet "_{([^\s$]*)" "subscript" iA
_{$1 `!p match.group(1)`$2}$0
endsnippet

however it does not work, and it seems that Ultisnips does not match the text after the cursor.

3
  • 1
    Welcome to Vi and Vim! You may have better luck with the plugin maintainers.
    – D. Ben Knoble
    Nov 14, 2020 at 20:10
  • Can you share an example of the snippet definition you're using? It seems you're using a snippet with autotrigger (A option), is that the case?
    – filbranden
    Nov 14, 2020 at 23:45
  • 1
    Hi, filbranden. Yes I am using the A option. I updated with my code that does not work.
    – Frid Fu
    Nov 15, 2020 at 17:26

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.