Vim: Snippets with multiple duplicate tabstop don't work.

Created on 1 Jan 2018  路  6Comments  路  Source: VSCodeVim/Vim

Is this a BUG REPORT or FEATURE REQUEST? (choose one):
BUG REPORT
What happened:
Simple snippet with duplicate tabstop doesn't work properly.
What did you expect to happen:
Expected to be able to replace the placeholder variables by simply typing over.
How to reproduce it (as minimally and precisely as possible):
"testsnippet": {
"prefix": "test",
"body": ["console.log('${1:test}'); ${1:test}"],
"description": "test snippet"
}
In new file type "test" and expand the snippet.

  • try to type to replace current selection - the typed text is added after the selection
  • try to backspace selection - not just the selection gets deleted but more characters to the right of it.

All snippets without duplicate tabstops (so ${2:test} for example as the second tabstop) work properly.

Environment:
Macbook pro, macOS Sierra,

  • Extension (VsCodeVim) version: 0.10.6
  • VSCode version: 1.19.1
  • OS version: 10.12.6
statuduplicate

Most helpful comment

You can kind of work around this (on mac at least) by doing Alt+Delete before starting to type.

All 6 comments

Having the same issue with my Arch machine. Does it have anything to do with how the multicursor is implemented?

I'm experiencing the same issue with snippets that use more than one of the same placeholder as @pocorschi describes.

Without the Vim extension enabled, I can expand a snippet and immediately begin typing to replace multiple placeholders at once.

With Vim enabled, when I expand the snippet and begin typing, the characters are added after the placeholders instead of overwriting the placeholders as expected. Note that this bug only occurs when there is more than one of the same placeholder in a single snippet. Snippets without duplicate placeholders work as expected.

You can kind of work around this (on mac at least) by doing Alt+Delete before starting to type.

@runningskull Thanks, that's very helpful. And it maintains the tab order to move on to the next tabstop after editing. Still hoping to see the actual issue resolved, though.

on Windows just Delete seems to be working for me. Thanks for giving me a clue @runningskull ... I was thrashing trying to figure out how to use react snippets with vscodevim. Agreed it is not intuitive and hopefully will be fixed.

Was this page helpful?
0 / 5 - 0 ratings