Barry Franklin
Barry Franklin

Reputation: 1820

Writing XML Snippets for XML in Visual Studio

I've written a number of XML snippets (specifically snippets for XML files) in Visual Studio and I'm encountering an issue where I use the snippet and am done with the replacement parameters and I want to get out of the replacement part of it, I hit enter at the end of the first line and it takes my cursor back to the beginning of the line.

This is one example:

<Code Language="XML">
  <![CDATA[ <loop id="$Id$" repeat="$Repeat$" ordinal="$Ordinal$">
          //intentional empty line left here
  </loop>]]>
</Code>

I have left out the declarations for brevity.

This snippet generates (with params filled in):

<loop id="1" repeat="10" ordinal="1">
    | <-- would like cursor to end up here
</loop>

And I would like the cursor to end up inside the tag, but when I go to the end of the first line and hit enter, the cursor moves to the beginning of the first line and I have to go back to the end of the first line and hit enter again.

This doesn't seem to me like expected behavior, but maybe it is.

Upvotes: 0

Views: 286

Answers (1)

Chrille
Chrille

Reputation: 1453

Use the end variable to position the cursor:

<Code Language="XML">
  <![CDATA[ <loop id="$Id$" repeat="$Repeat$" ordinal="$Ordinal$">
          $end$
  </loop>]]>
</Code>

From MSDN:

$end$ marks the location to place the cursor after the code snippet is inserted.

Upvotes: 1

Related Questions