How to automatically expand snippets without opening suggestion window in VS Code? - visual-studio-code

I've installed VS Code extension named dsznajder.es7-react-js-snippets to quickly type boilerplate ES7 code.
So when I type imd a quick suggestion shows up
and then by pressing Tab this snippet expands
I want to get the following behavior:
Disable Quick Suggestion so it will not be showed up automatically
Create keyboard shortcut which, after I typed imd, and called shortcut will expand snippet automatically (without showing suggestion / autocompletion windows and needing to navigate to snippet)
How would I do that?

Add the following to your user settings:
{
"editor.tabCompletion": true,
"editor.quickSuggestions": {
"other": false,
"comments": false,
"strings": false
}
}

See:
// Control whether an active snippet prevents quick suggestions.
"editor.suggest.snippetsPreventQuickSuggestions": false,
so suggestions do not intrude while completing a snippet.

Related

How to get rid of automatic auto complete in VS code

I'm getting autocomplete without prompting for it by pressing any buttons, menu items, hint popups, or keyboard shortcuts.
I am not sure if it's due to some extension I added. I am new to coding and while this autocomplete is helpful, it wouldn't make me a better programmer. I was wondering how to turn off this setting in VSCode window.
I want them to be totally off.
For the most part, quick suggestions can be disabled for with the following config:
"editor.quickSuggestions": {
"comments": "off",
"strings": "off",
"other": "off"
}
If you want to have different settings per language, you can do it like so (using C++ as an example):
"[cpp]": {
"editor.quickSuggestions": {
"comments": "off",
"strings": "off",
"other": "off"
}
},
From your screenshot, it looks like you have these values set to "inline", which shows them as "ghost text".
Specifically for C++ (and perhaps for similar scenarios with other languages), the quick suggestions may still pop up after typing some characters such as the scope resolution operator (::), but most cases of it will be disabled with this (and I don't know how to fix those specific cases or why they happen (might be worth issue tickets with the tool maintainers)).
This allows you to still trigger autocomplete suggestions by pressing the registered keyboard shortcut. If you actually want to entirely disable intellisense for whichever programming language and extension you are using, that generally just means disabling/deactivating that extension, or using specific settings for that extension to disable intellisense.

VS Code Stop Showing InlayHints Types on methods/functions/objects/etc

I have enabled viewing the types in VS Code, and now I don't remember how to turn it off or where I turned it on.
I've disabled all my extensions to make sure it wasn't one of them haha. So it looks like a VS Code Setting I can't seem to find.
As shown above here pointed out by the red box and arrows.
Greatly appreciate it, driving me crazy at the moment however very helpful at first.
I found it, hope this helps someone else - it was the inlayHints for javascript displaying all that.
Open up settings for VS Code, Ctrl + Shit + P to open command palette, type "Open Settings" and selected the JSON option. I had the following set to true, switched to false.
"javascript.inlayHints.enumMemberValues.enabled": false,
"javascript.inlayHints.functionLikeReturnTypes.enabled": false,
"javascript.inlayHints.parameterNames.enabled": "all",
"javascript.inlayHints.propertyDeclarationTypes.enabled": false,
"javascript.inlayHints.parameterTypes.enabled": false,
"javascript.inlayHints.variableTypes.enabled": false,
You can find it under Inlay Hints via the UI too rather than editing json:

Only show relevant intellisense suggestions in VSCode editor

This problem is difficult to explain.
In the image below, how do I get VSCode to only show adjL? I only want suggestions from the file I'm currently editing.
Currently, it shows a whole list of variables that I don't ever use.
See here: https://code.visualstudio.com/docs/editor/intellisense
Adding this to your setting.json should do it.
"editor.quickSuggestions": {
"other": false,
"variable": true
}
But I not recomended that, because intellisence is realy helpfull! ;)
Unless you only care about hiding other variables but not other types of prompts.

How can I disable this box on VS Code?

I've searched through similar questions, and couldn't find an answer. It's that box that keeps opening whenever I push Enter, and proceed to include another style component on my stylesheet.
Most of the times it covers a lot of the code when it appears, and this is kinda bothering me. Thanks in advance!
You could stop quick suggestions by adding the following snippet in settings.json
"editor.quickSuggestions": {
"other": false,
"comments": false,
"strings": false
}
Or if you just want to disable only emmet abbreviations, you could do so by adding this property in settings.json
"emmet.showExpandedAbbreviation": "never"
More information about various intellisense and emmet abbreviations settings could be found in the following pages
VS Code intellisense settings
VS Code Emmet settings

VSCODE snippets : Force intellisense after only one character pressed

I'm new to VSCode and I want to test it to compare with my sublime text configuration. I want to create a very simple snippet that allow me to write ruby code <%= %> when I only press < key.
Here is my snippet's code :
"My snippet": {
"prefix": "<",
"body": [
"<%= $1 %>"
],
"description": "My snippet"
}
So this code works but I have to press Ctrl+Space in my file to show the IntelliSense list (with my snippet). I just want to press < and Tab to complete this, not to press Ctrl+Space always.
Do you know if there's a configuration to do it ?
Thanx
It is a long time since your question, but I think it may help others.
In settings you need to enable editor.tabCompletion, then you can press tab even if there is no IntelliSense.
To have the snippet auto-injected into the VS Code Editor when you press Tab after the prefix (even this is only one character), you need to set the editor.tabCompletion setting to onlySnippets, neither off nor on.
"editor.tabCompletion": "onlySnippets",
personally, I think this is a very strange behavior, and that, in theory, with the value on the tabCompletion option should also work. but somehow this option works like that, at least for me.
There are two configuration values you can set in order to let VSCode show suggestions and snippets immediately.
// Controls if quick suggestions should show up or not while typing
"editor.quickSuggestions": true,
// Controls the delay in ms after which quick suggestions will show up
"editor.quickSuggestionsDelay": 0,
With this setup suggestions popup as soon as possible.