1

I am using VSCode Hypersnips (based off of Vi's https://github.com/SirVer/ultisnips), following this guide . See also Create-Snippets-For-Ultisnips.

Consider the following example: I have a snippet

snippet fm "inline Math" wA
\(${1}\) $0
end snippet

and another snippet

snippet ( "parenthesis" wiA
($1) $0
end snippet

If I were to type fm, then that would produce \(|\) |, where the first | is where my cursor is, and the second | is where my cursor would be if I pressed <Tab>. Now, when I type fm ( hi <Tab> that produces \((hi) |\) as expected, but when I press <Tab> again (hoping to use the $0 tab stop of the fm snippet), I don't get outside the right \) like I want, and instead a tab character (i.e. 2 spaces) are placed where the cursor is.

I am wondering if I can nest snippets like this, and still use the tab stops of the outer snippet once I exit the inner snippet.

I assume the same issue occurs if I use native VSCode snippets.

StackOverflow informs me that a similar question has been asked: Atom - Nested snippets with tab stops error, but not about VSCode's snippets.

1 Answer 1

0

It seems this is known issue: https://github.com/draivin/hsnips/issues/78. This is a summary of the issue from Dec. 2 2021:

So, I looked into it, the placeholder disappearance is caused by a workaround we are currently using to get around a VsCodeVim issue.

History time:

We started using the workaround to get around this issue Trigger A leaves me in visual mode, I want it to leave me in insert mode instead #28.

Supposedly, the related issue in VSCodeVim was fixed here Snippet is not working Properly VSCodeVim/Vim#5240.

I'm not sure if it was never properly fixed, or if a regression happened, but it seems that the issue still exists (see Unexpectedly entered visual mode in snippet VSCodeVim/Vim#7068), so while that issue is still open, we can't remove the workaround and fix this bug.

For now, https://github.com/draivin/hsnips/issues/126 offers what I think is the best solution, namely using VSCode Neovim.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.