Visual Studio 2017: Disable Intellisense for CodeSnippets
Asked Answered
R

4

5

I'm using Visual Studio 2017 Enterprise, Version 15.3.3

I looks like IntelliSense has some new features for code completion. On of this feature is, that a field name is automatically suggested when a type is written.

SpacePosition s.. // starting with s, Intellisense suggest "space", "position" and "spacePosition"

snippedFeature on tab

I like this feature in general but not for code snippets. Using a code snipped I have the problem, that the name of a literal is automatically replaced by IntelliSense after pressing tab (which is used for navigate to the next literal).

In my example I want to name the property "other" and then jump the the next literal inside the snippet. But because of IntelliSense, the property name is replaced by "spacePosition".

Is there any way to disable the IntelliSense feature inside code snippets?

I found a solution for the same problem in Visual Studio Code: stackoverflow article but not for Visual Studio

Rees answered 5/9, 2017 at 11:6 Comment(4)
Now there has no such option to disable this intellisense feature inside code snippets, but you can try to click 'Esc' key after type 'other', then click 'Tab' key to jump to next literal, please check this: 1drv.ms/i/s!Atv5QNuFrncKgymwBXklXjEatOkNByplay
@Sara: Thank you for the workaround and the short video :-). Works for me.Rees
Hi, so glad to hear that your issue is solve and I added a reply, could you please mark it as answer when you have free time? That will help other community members to easier search this information, thanks. :)Byplay
It is actually a name suggestion. Can be turned off. An 'Esc' is not a solution, it's a band-aid over a new 'cool' feature.Implosion
I
8

Disable the name suggestions in Tools/Options/TextEditor/C#/IntelliSense. That's what is causing this nonsense. Seems MS realized later that they flipped coders up by adding that feature that changes old behaviour greatly without giving them a way to disable it. Now there is such a checkbox. Tools/Options/TextEditor/C#/IntelliSense I nearly uninstalled this studio because of this lol. Not sure, may be it's a good feature, but i'm too used to Tab code snippets around, that I'm better without it.

Implosion answered 28/8, 2018 at 8:27 Comment(0)
I
1

How to: Manage Code Snippets

To access the Code Snippets Manager

1.) On the Tools menu, click Code Snippets Manager. Shortcut Ctrl+K,Ctrl+B

How to: Change snippet behavior

To change snippet behavior.

1.) Go to Tools > Options > Text Editor > IntelliSense > Snippet Behavior

2.) See images. enter image description here

Intro answered 5/9, 2017 at 13:49 Comment(1)
Tank you for your proposal. But that is not what I want. I don not want to disable snippets when tab is pressed. I want to disable Intellisense after a snipped was insert. I have updated my question to make it clearer.Rees
B
1

Now there has no such option to disable this intellisense feature inside code snippets, but you can try to click 'Esc' key after type 'other', then click 'Tab' key to jump to next literal, please check the following: enter image description here

Byplay answered 7/9, 2017 at 1:21 Comment(0)
F
1

This actually works correctly in Visual Studio 2019 for classes if it is a class that is valid for the current context (i.e. Doesn't exist in a namespace not in the current class namespace or in the using statements for the file).

Here is my example snippet

Snippet Definition enter image description here

Snippet Use

enter image description here

And here is an example where I use two different classes as the second snippet, one that is a valid class name and works to use tab to autocomplete, and one doesn't work because the class requires adding an additional namespace using statement that is currently missing from the file:

enter image description here

So I see two options.

  1. Use the sucky to cancel any auto-complete logic.
  2. Ensure you have the proper using statements. You can even add using statements to your snippet using the imports declaration: enter image description here
Fahy answered 30/4, 2020 at 15:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.