0

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.

2
  • 2
    Which IDE?..... Commented Jan 24, 2018 at 12:13
  • @spender - VS - just added that. Commented Jan 24, 2018 at 12:14

1 Answer 1

1

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.

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

1 Comment

I knew there was a tag that I was missing!

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.