snippets icon indicating copy to clipboard operation
snippets copied to clipboard

Allow context around tab stops

Open tinloaf opened this issue 10 years ago • 2 comments

Hi,

I have a couple of snippets like the following:

func(${1:arg1}, arg2 = ${2:defaultValue})

Now, you sometimes do not want to set arg2. In Python for example, it can make a difference whether you omit an argument or set it to its default value. Thus, when I reach tab stop 2 and hit "delete" or "backspace", I would like ", arg2 =" to disappear with it.

I would offer to implement this, but I'm not sure how to expand the tab stop syntax without breaking compability.

tinloaf avatar Apr 07 '15 10:04 tinloaf

Hey tinloaf,

As a temporary fix, the behavior you describe could be emulated with an extra tabstop:

func(${1:arg1}${2:, arg2 = ${3:defaultValue}})

After pressing tab the second time, everything after the comma would be selected and ready to be deleted if not needed. The third tabstop would be deleted along with it.

**Edit: Just noticed however, the above snippet tiggers a bug where the tab marker for the second tabstop is not updated as you write text for the first tabstop. Though i do believe the above snippet to be valid.

soren-n avatar Apr 07 '15 14:04 soren-n

:+1:

steveoh avatar Jun 03 '15 00:06 steveoh