Is it possible to define tab order for Visual Studio snippet replacement parameters?

  Uncategorised

Say I have following code snippet for C# code:

<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
    <CodeSnippet Format="1.0.0">
        <Header>
           <Title>My math function</Title>
           <Author>Myself</Author>
           <Description>Calculates my math function.</Description>
           <Shortcut>mymathf</Shortcut>
        </Header>
        <Snippet>
          <Code Language="CSharp">
            <![CDATA[double result = Math.Sqrt($Number1$) + $Number2$;]]>
          </Code>
          <Declarations>
            <Literal>
              <ID>Number1</ID>
              <Default>16</Default>
            </Literal>
            <Literal>
              <ID>Number2</ID>
              <Default>5</Default>
            </Literal>            
          </Declarations>
        </Snippet>
    </CodeSnippet>
</CodeSnippets>

This snippet is invoked with mymathf keyboard shortcut and it takes two replacement parameters $Number1$ and $Number2$: double result = Math.Sqrt($Number1$) + $Number2$;

By default Visual Studio editor will ask me to first populate $Number1$ and then, after I hit tab key, $Number2$.

Is it possible to define order of this? For example in this case I’d like to first populate $Number2$ and then $Number1$.
I am using Visual Studio 2019.

Source: Visual Studio Questions

LEAVE A COMMENT