I have a piece of code string.Format(@"") with a sf label that inserts a fragment and places the cursor between two double quotes. Really comfortable. Of course, I can use it by simply typing sf and double-clicking the tab:

However, I just found that the shortcut does not work in all places. For example, if I create this statement:
if(true) throw new FormatException() // <-- cursor is inside these parens
and I pressed sf , the shortcut does not appear on the intellisense menu, and if I press Tab twice, it will not generate a fragment. Why?
I tried looking for “C # code snippet script sometimes doesn’t work”, “C # code snippet shortcut doesn’t work”, “Visual Studio code snippet sometimes doesn’t work”, among others, and I can’t find anything useful.
EDIT: Here is the fragment definition:
<?xml version="1.0" encoding="utf-8"?> <CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"> <CodeSnippet Format="1.0.0"> <Header> <SnippetTypes> <SnippetType>Expansion</SnippetType> </SnippetTypes> <Title>String.Format with @</Title> <Author>Rory</Author> <Description> </Description> <HelpUrl> </HelpUrl> <Shortcut>sf</Shortcut> </Header> <Snippet> <Declarations> <Literal Editable="true"> <ID>anchor</ID> <ToolTip> </ToolTip> <Default> </Default> <Function> </Function> </Literal> </Declarations> <Code Language="csharp" Delimiter="$" Kind="method body"><![CDATA[string.Format(@"$selected$$end$")]]></Code> </Snippet> </CodeSnippet> </CodeSnippets>
rory.ap
source share