SurroundsWith cannot be selected


Steps to reproduce:
  1. Create new snippet file as documented.
  2. Enter some code.
  3. Change "Snippet Type" property to "SurroundsWith".
Expected behaviour:
Snippet type property changes.

Actual behaviour:
Snippet type property doesn't move anywhere and remains "Expansion".


mmanela wrote Jul 6, 2012 at 3:56 PM

What version of Visual Studio are you using?

LonelyPixel wrote Jul 10, 2012 at 11:01 AM

Visual Studio 2010 Pro

mmanela wrote Jul 14, 2012 at 11:19 PM

I looked into and this is not a bug but a failure of messaging.
In order to select SurroundsWith you must first add the special placeholder $selected$ to your snippet. A SurroundsWith snippet will replace the $selected$ placeholder with the code your snippet is surrounding.

The Snippet Designer should probably alert you so that you can be more aware of this when you choose surroundswith.

Let me know if that works for you.

LonelyPixel wrote Sep 24, 2012 at 3:59 PM

As soon as I type $selected$ and click on the property grid row with "Snipper Type" once, the type changes to "SurroundsWith". So actually, I think that property should not be settable at all, and the snippet type if only determined by the existence of "$selected$" in the script. Is this actually documented somewhere? Anyway, I'm trying to find out how a SurroundsWith snippet is actually used, because the only way to use snippets that I know is type in the snippet shortcut. This cannot be at the same time while some other text is selected.

mmanela wrote Sep 24, 2012 at 4:43 PM

That is a good suggestion. I agree that the existence of the $seleceted$ should determine the type. And this isn't documented anywhere on this site but I can add a page to help clear this up.

You can select surroundwith from the right click menu. There is an option called "Surround With"