Home > Enterprise >  Visual Studio 2022 Snippets not working for C#
Visual Studio 2022 Snippets not working for C#

Time:11-12

I did a fresh install of Visual Studio 2022 v17.0.0 (.NET 6.0) and created a new WebAssembly project. Tried editing Counter component but none of the snippets work for C#.

Typing cw is supposed to bring up Console.WriteLine but nothing happens, tabbing does nothing but insert tabs. Tried several other snippets and same results. If I enter Console. I should get suggestions popping up but I get nothing.

I tried doing a repair installation but didn't fix the problem. Any suggestions as to what else I can try to fix. Thanks

CodePudding user response:

  1. Go to tools/options/texteditor/advanced and check that default intellisense completion mode is automatic.

Then I have the cw snippet appearing, and it is inserted after typing twice tab:

cw snippet intellisense

  1. With ctrl k, ctrl b check that your snippets are present; if there is a problem here, you may have a problem with your snippet file.

Other remarks:

  1. Do not log in as user as it may rewrite you parameters.

  2. If a repair does not work, deinstalling then installing again VS will give a cleaner install.

CodePudding user response:

I had the same problem but managed to get things working again. In the Code Snippets Manager (CTRL K CTRL B) I noticed my snippets folder had the same name as another folder ("Visual C#"). I removed my folder from Code Snippets Manager, renamed it in File Explorer to be unique when in the Code Snippets Manager, then added it back in to Code Snippets Manager.

I then had to restart my Visual Studio 2022 before it recognised my snippets.

Following that, it seems I can edit my snippets without having to restart VS. I'd say VS 2022 has a problem with the initial recognition of the custom snippets folder.

  • Related