JavaScript snippets in Code Snippets Manager not showing up in Intellisense

299 Views Asked by At

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

There are 1 best solutions below

5
On BEST ANSWER

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.