Search code examples
c#visual-studiocode-snippets

Visual studio customized snippet not shown on suggestions bar


I have a code snippet I made and I want to use it during writing code, the problem is that the Inteli-sense not suggest the snippet I made even though I can see it was added as expected in the snippet manager window.

the snippet:

<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
  <Header>
     <Title>xvar</Title>
     <Author>Michael Gabbay</Author>
     <Shortcut>xv</Shortcut>
     <Description>Expand a variable lambda expression</Description>
     <SnippetTypes>
        <SnippetType>Expansion</SnippetType>
     </SnippetTypes>
  </Header>
<Snippet>
    <Code Language="csharp"><![CDATA[(x=> x)
                        ]]>
    </Code>
 </Snippet>
</CodeSnippet>
</CodeSnippets>

Here you can see it was loaded successfully:

enter image description here

My expected result was to see the suggestion as described below:

enter image description here

Note - I'm using Vs2022.


Solution

  • I tested your code and there is no problem. Did you do something wrong? Did you try to restart the compiler?

    enter image description here

    1.

    enter image description here

    enter image description here

    2. Tools->Code Snippets Manager

    Click import:

    enter image description here

    3. Output:

    enter image description here

    My version:

    enter image description here

    Best Regards,

    Jiale