0

In Visual Studio 2019, I have imported a snippet using Tools -> Code Snippets Manager per the Microsoft Walkthrough documentation.

I can see it in Code Snippets Manager.

enter image description here

Here is the content of my snippet.

<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  <CodeSnippet Format="1.0.0">
    <Header>
      <Title>switch</Title>
      <Author>Me</Author>
      <Description>Inserts a switch case.</Description>
      <Shortcut>cmswitch</Shortcut>
    </Header>
    <Snippet>
      <Code Language="JavaScript">
        <![CDATA[ switch ($switch_on$) {case 0: break; default:}]]>
      </Code>
      <Declarations>
        <Literal>
          <ID>switch_on</ID>
          <ToolTip>Enter the switch case criteria.</ToolTip>
          <Default>switch_on</Default>
        </Literal>
      </Declarations>
    </Snippet>
  </CodeSnippet>
</CodeSnippets>

When I try to use the snippet by typing cm in a basic .cshtml file, I get nothing.

enter image description here

Any idea why my snippet is not showing up in intellisense.

1 Answer 1

1

In fact, it is an issue on VS2019. I also have the same behavior in my side with VS2019.

The Code Snippets Manager listed the code snippet which proves that VS has enabled that snippet. I can even insert code snippets manually and it seems that the shortcut does not work on VS2019.

However, when I tested the issue on VS2017. It can works well. So I am curious whether the issue is related to VS2019 itself.

VS2017:

enter image description here

I have reported the issue on our DC Forum. And you can vote it and add any comments if I did not describe the issue in detail so that it will get more Microsoft's attention. And I hope the Team will give you a satisfactory reply.

And since the process might take a long time, you have to right-click on the code editor-->Insert Snippet to add your own snippet manually to get what you want.

====================================

Update 1

report the issue on forum again.

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

5 Comments

Thank you for logging it in the Microsoft forums. I have added some supporting tests of aspx, js, cshtml, and html files. None of which work with the snippet for javascript.
Thanks for your feedback. And this is a real issue on VS2019 while I used it well on VS2017. Since we cannot do any other things here, I suggest you could accept this answer to let other community members know it is a real issue. And I will follow the DC problem and let you know any reponse.
Got it. Thank you for the help! I hope they can fix it.
@cmill, the switch title of your code snippet has a conflict with the system code snippet. Please reanme the title like JSswitch and then restart VS. I could find the cmswitch.

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.