VSCODE snippets : Force intellisense after only one character pressed - visual-studio-code

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.

Related

Suppress syntax function help popups in VS Code/VSCodium

I'm using VSCodium to write some Python, and using the Python/Intellisense/Pylance Extension and an annoyance is the constant pop-ups explaining every basic function to me.
For example if I start to type a print() statement it pops up a large box with all the syntax details of writing a print statement, which blocks my view of much of my code. I'd like to just be able to type without the big pop-up suggestions.
I tried under the Preferences > Settings > text editor and there are pages and pages of "suggest:" option check boxes there, and though I tried several, none helped. Not sure if that's the right place to look.
I tried to change the Quick Suggestions Delay to 5000ms but it seems to have no effect on that instant popup on typing print( as well.
I'm starting to think perhaps there is another set of settings that controls this, but there are so many and none seem to be making a difference.
I am using editor.quickSuggestions and editor.suggestOnTriggerCharacters turned off for that purpose:
"editor.quickSuggestions": {
"comments": "off",
"strings": "off",
"other": "off"
},
"editor.suggestOnTriggerCharacters": false,
…and it works for me for languages I am using; not using Python at this point.

VS Code Autocomplete Doesn't show after using it

it's a simple problem that has been bothering me for a long time, when I use autocomplete, the text I write after it becomes highlighted and suggestions don't show up anymore, does anyone know how to disable it?
it goes back to normal after pressing ESC
Video Example
The Solution is to go to VS Code Settings and disable following setting:
"editor.suggest.snippetsPreventQuickSuggestions": false // enables suggestions

VS Code - Turn off auto close tags, but leave on autocomplete

Recently switched from Sublime Text 3 to VS Code. Overall pleased with the switch except for this one little thing that's just annoying enough to be a dealbreaker if there's no solution. In ST3 if I type, say, a <div>, it doesn't automatically drop in a </div>, which is nice because I'm often pasting it in and don't want it closed right there.
What ST3 DOES do, however, is complete the tag the moment I type </. It autofills div> the moment I type the forward slash. This is the behavior I want from VS Code. I can't find any mention of this anywhere which is completely baffling. I know how to autoclose tags, but that's no good becasue then I have to manually close them. I want VS Code, like ST3, to autocomplete the tag for me, just not immediately.
Go to File > Preferences > Settings, search for html.autoClosingTags and set it to false.
This will make it so when you type <div>, it won't insert </div> automatically, but if you start typing </, it won't close the tag automatically. You can press ENTER to make it autocomplete for you.
Or you can leave this option enabled and when you type <div> and it autocompletes, you can just press CTRL + Z.
More information on this behavior here.
Add this to settings.json to make it work like Sublime Text:
"html.autoClosingTags": false,
"auto-close-tag.SublimeText3Mode": true
Go to Settings, search for "auto closing" and enable/disable these options as needed
Or set them in your settings.json file like so:
"html.autoClosingTags": false,
"typescript.autoClosingTags": false,
"javascript.autoClosingTags": false,
On Windows/Linux - Ctrl + Shift + P
On MacOS - Cmd + Shift + P
In the search box type settings.json
paste the following line there
"html.autoClosingTags": false
A very simple trick i learnt
If you want to disable tags auto completion for just a single task for example. To save a file without vscode adding closing tags. Just set a different language mode for that file.
Change from the inferred one i.e html to Batch, Diff ignore. The options on vscode are many. This will enable you to save the file without addition of any closing tags.
After you are remember to reset the language mode to Auto Detect.
TLDR;
To access language mode-:
Use the command pallete and search Change Language Mode or
Find a shortcut at the bottom right section on Vscode.

How to disable Ctrl-Click in VS Code

I want to know if it's possible to remove the key bind on Ctrl-Click for the goToDefinition (F12) editor action.
This is so annoying, every time i try to Ctrl+C/V it trigger and go to the definition cause I'm holding Ctrl while I'm highlighting the code with my mouse.
I have search for it on google but all y can change is the F12 key bind for goToDefinition which is not what I want.
--- Update
This is the feature I want to disable
I need to remove the ctrl+click key bind.
Even if I replace it, it doesn't work.
-- Update 2
I finally found something on the subject Here
But for me it doesn't work at all.
-- Update 3
Created a new issue on GitHub (#7827)
Look at it if you wanna see the update on the request.
At the time of writing (2022) you can turn off this with workaround by setting following setting to 'ctrlCmd'.
How to open setting page in vs code?
Ctrl+Shift+P and enter open setting (UI)
Note that if you are also looking for Ctrl+Click for word selection, it is still not possible. See my another answer.
And yea, the dreaded (and famous) issue #3310 is never really happened, even after 6 years.
There is a VS Code feature request for this on GitHub, under the more general heading Allow customization of mouse shortcuts.
Anyone interested in this VS Code feature should comment/vote there. (The Ctrl-click-specific GitHub posts have been closed off and linked to this one. Ex. #16974)
Add the following lines in keybingings.json to disable (actually override default behaviour) mouse+ click
[
{ "key": "ctrl+[mouse button]", "command": "cursorWordLeft",
"when": "editorTextFocus" }
]
To open key bindings file, traverse
File > Preferences > Keyboard Shortcuts

How to activate Markdown user snippets in Visual Studio Code?

User Snippets are an awesome feature of Code, however, I can't get them to work for Markdown files. A markdown.json file exists and is editable, but I can't get snippets defined in that file to activate (using Tab like for other languages). Is there a different activation method for these snippets or are they just not supported yet?
EDIT: Here's the contents of the markdown.json file just in case I'm doing something wrong there.
{
"Markdown comment": {
"prefix": "comment",
"body": [
"<!--- \n --->"
],
"description": "A Markdown comment"
}
}
Open the editor
Go to File -> Preferences -> User Snippets
Select Markdown. The file C:\Users\YOU\AppData\Roaming\Code\User\snippets\markdown.json will be opened
Paste your snippet into the file and save it
From now on you can use the snippet in all .md files.
In case the snippet suggestion doesn't popup when you type "comment" then you should type CTRL + Space to force it.
https://github.com/Microsoft/vscode/issues/26108
in case you mean no popup quick suggestion, the link is the cure.
"editor.quickSuggestions": true
add this to user setting then you should be able to see the popup snippet suggestions
https://github.com/Microsoft/vscode/issues/1617#issuecomment-166999086
Full extensions get auto (7x24) completion by default (e.g. latex, cake), some built-in extensions like Markdown do not.
You have to type CTRL + Space to force it.