14

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

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
user1068557
  • 309
  • 2
  • 8

5 Answers5

18

Most likley it is functioning but I found that VS 2022 made som changes to the default behaviour.

Make sure that when you type your phrase in the the document that it is appearing on top of the suggestion box. Example showing suggestion

If not press ctrl + alt + space. Try again. Example not showing suggestion

If you are experiencing that the phrase you are typing is not default selected when you try to tab out your snippet you may want to change your IntelliSense behaviour from 'Include snippets when ?- Tab....' to 'Always include snippets'.

Tools > Options > Text Editor > C# > IntelliSense > 'Always include snippets'

Best of luck, fingers crossed, godspeed and all that. =)

kejsarn
  • 181
  • 1
  • 4
  • This works. Have no idea how it got turned off. I have not touched it but it got set to Never on an update or something else (keypress?). Anyway, 'Always include snippets' worked. – AlanC Feb 08 '22 at 18:16
2

For me only enabling Always include snippets didn't work. With the Visual Studio 2022, Version 17.4.3 I had to disable the Show new snippet experience (experimental) option in the Tools->Options->Text Editor->IntelliSense. There is no need to restart VS.

BDisp
  • 99
  • 6
1
  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.

Soleil
  • 6,404
  • 5
  • 41
  • 61
  • 1
    Yes that is already set to Automatic. Problem persists – user1068557 Nov 10 '21 at 20:30
  • 1
    @user1068557 I installed VS2022 in a VM without registering any user (it may rewrite your parameters if different). Do you repro your problem in that case ? – Soleil Nov 10 '21 at 21:40
  • 1
    @user1068557 please check with ctrl+k,ctrl+B that the `cw` snippet is here also – Soleil Nov 10 '21 at 21:48
  • 1
    I ran installCleanup.exe -f for a complete removal of VS and reinstalled VS but same problem. ctlr+k ctrl+b shows the cw snippet. When I type cw I don't get the tooltip popping up like the screenshot above shows so there is nothing to tab select. Other snippets like prop and for do not work either. – user1068557 Nov 11 '21 at 01:15
1

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.

Zodman
  • 3,178
  • 2
  • 32
  • 38
0

If you re-add the snippets and restart Visual Studio it works.

In my case, if I copied the folder in the picture and opened in explorer it seems like the folder doesn't exist. But if I press "Add" and navigate to this folder it does exist and I can add the default snippets again.

enter image description here

sfs
  • 431
  • 8
  • 16