Visual Studio Code Snippets Cursor

In Visual Studio, when you insert a fragment and finish inserting literals, the cursor jumps to the beginning of the fragment.

Now I want to tell the visual studio where the cursor should go afterwards. I searched the Internet and practically did not hope that this would be possible.

To illustrate, suppose I have this snippet:

<Code Language="csharp" Kind="method body" Delimiter="$"><![CDATA[this.SyncThreadRunInvoke(() => { });]]> </Code> 

Then after insertion:

 this.SyncThreadRunInvoke(() => { []<- I want the cursor here }); 
+43
visual-studio code-snippets
Jan 20 '10 at 9:26
source share
1 answer

Use the $ end $ variable, as shown in the following if if if snippet.

 <?xml version="1.0" encoding="utf-8" ?> <CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"> <CodeSnippet Format="1.0.0"> <Header> <Title>if</Title> <Shortcut>if</Shortcut> <Description>Code snippet for if statement</Description> <Author>Microsoft Corporation</Author> <SnippetTypes> <SnippetType>Expansion</SnippetType> <SnippetType>SurroundsWith</SnippetType> </SnippetTypes> </Header> <Snippet> <Declarations> <Literal> <ID>expression</ID> <ToolTip>Expression to evaluate</ToolTip> <Default>true</Default> </Literal> </Declarations> <Code Language="csharp"><![CDATA[if ($expression$) { $selected$ $end$ }]]> </Code> </Snippet> </CodeSnippet> </CodeSnippets> 
+69
Jan 20 '10 at 9:44
source share



All Articles