How to exit IntelliSense suggestions in VSCode, and/or add suggestions? - visual-studio-code

I'm working in Visual Studio Code, and I would like to know how to exit out of IntelliSense suggestions. Whenever I press enter, the first suggestion is automatically selected, and this is causing me problems, so I would like to know of a way to exit IntelliSense before pressing enter. I know I could change the settings to not automatically select when I press enter, but I prefer using enter for most things so I'd rather not if possible.
My biggest problem is, I'm using Haxe and VSCode keeps automatically correcting "else", in an else statement, to the variable "elapsed". So if there's a way to add "else" to the list of suggestions that would probably work too.

The default keybinding to exit IntelliSense is esc
This is bound to the hideSuggestWidget command. You can change the keybinding as described here

Related

vscode: pasting autocomplete with return key sometimes doesn't work

VSCode often suggests symbols as you type e.g. a variable or field name. When the correct variable name is suggested, usually I can press return to paste the suggestion.
This used to work all the time, now it only works often. And it's driving my crazy. Now, sometimes, when I press return, it actually enters a return character instead of the selected symbol.
Any ideas how to troubleshoot?
Relevant info:
I'm writing rust, with the popular rust-anayzer extension.
I'm on Ubuntu 22.04 LTS
Not sure what I should google for, or where to look for potential problems.
I had this issue before.
One possible reason why VSCode is occasionally inserting a return character instead of the selected symbol is due to conflicts with keyboard shortcuts. It's possible that another application or system function is also using the same keyboard shortcut as the "Enter" key, causing it to be triggered unexpectedly.
I solved it by resetting VSCode settings to their default values.
You can do this by going to the VSCode "Settings" page (File > Preferences > Settings) and clicking the "Open Settings (JSON)" button at the top right. Then, delete all the contents of the JSON file and save it. This will reset all your VSCode settings to their default values.

VSCode - Disable selection on auto-complete suggestion

Whenever I use autocomplete, VSCode automatically puts whatever I type in a selection, it didn't happen before and it only started happening recently.
Here's what happens:
I type something like this and suggestion comes up:
Then I press enter to auto complete:
All of this is fine, but when I start typing in the quotes:
VSCode automatically puts my text in a selection. This causes multiple problems. Suggestions get disabled in selection and I have to press Esc everytime I want the selection disabled.
Is there any way to fix this?
The question was already answered by #Anton Solomin and #devanil. The issue is VS code auto-suggestion is not working when text is highlighted, because some of your code snippet is preventing quick suggestion by VS code.
So just tell VS code that don't disable quick suggestion if some snippets askes you to do it.
Go to VScode settings page, in settings search bar type editor.suggest.snippetsPreventQuickSuggestions
Uncheck Controls whether an active snippet prevents quick suggestion

How to get keyboard shortcut `Cmd + S` to save on VS Code?

When I attempt to save my file on Visual Studio Code with the cmd+s keyboard shortcut, it does not save the code. I have to manually click File, the Save, just to be able to save my progress. I'm using macOS Catalina version 10.15.7 and VC Code version 1.55.2.
How do I fix this?
Attempts:
-Checked if ⌘ Cmd + S keyboard shortcut is tied to the Save functionality
If you do it right this solution will fix your issue.
I have never had a problem saving with VS-Code personally, but I have had issues with keybindings. IDK if you write your own keybindings, but if you do, you might want to check the keybindings that you have wrote to make sure they do not conflict with [CTRL + S]. The keybindings.json file that you create custom keybindings in, overrides the default keybindings.json file that defines the keybindings that VS-Code ships with.
To check your keybindings.json file...
Hit the F1-Key
A menu will drop open type in "Keyboard Shortcuts"
There will be two Preferences: Keyboard Shortcuts
Make sure to select Preferences: Keyboard Shortcuts and not Preferences: Default Keyboard Shortcuts
If the file is empty you are good. If you have keybindings written in the file, you need to iterate through them by hand, checking each one. Make sure that none use [CTRL + S] together. Even if the keybinding uses [CTRL + S] and other keys, you will need to disable it, so you can test if it is causing an issue.
Debugging [CTRL + S]
If your keybindings.json file is all good, then great, that's one thing to scratch off the list. The only thing left to do now is debug the Bound Key ("Key Binding"). To debug keybindings, you will use a built in tool, that VS-Code offers. To start do the following:
Hit the F1-Key
When the quick input drops open type the following into the text input:
"Toggle Keyboard Shortcuts Troubleshooting"
Select the option: Developer: Toggle Keyboard Shortcuts Troubleshooting
It should automatically open the OUTPUT panel, which is located in the same panel that your terminal is. Make sure that the OUTPUT is set to LOG(Window) in the drop down. (I took a picture and posted it below if you can't find the Keyboard Shortcut Troubleshooter).
The image might have funny declensions because I am on a dual monitor setup with 1 1080x1920 curved screen and one 1080x720 screen.... I cropped it to a STD HD 1920 width.
I Got My Trouble-shooter working, and Output open, now What Jay?
Okay... Well your at the right spot. Now every-time you press some keys, you should see your OUTPUT WINDOW working like crazy. It should be logging all sorts of stuff, which is good, very good.
This Part Is Important! READ CAREFULLY
What you want to do is use your keybinding that you feel isn't working appropriately. Use it when focus is set on an editor, use it when focus is set on a different editor, use it when focus is set on the sidebar. Where you are focused at in the editor at any given time can greatly affect a keybinding. The output is gonna write lines every-time you use your keybinding. Try not to hit any other keys while doing this, so you have a column in you output that includes logging from the keybinding you are testing only. Read the output see what it says. See if it looks right, or wrong. If it looks wrong, you can visit this link, to the VSCode site that covers this topic, and see if you can fix it your self. If you can't fix it your self, come back here, and edit your question. When you edit your question make sure that it includes the Troubleshooter's Logging Output.
VSCode Troubleshooting Keybindings (Keyboard Shortcuts) # https://code.visualstudio.com/docs/getstarted/keybindings#_troubleshooting-keybindings
Image that shows how to open the Keyboard Debugger
Also shows how to set the OUTPUT to Log(Window)
StackOverflow-2021-JUNE-26018:34-PST
Another thing to check for is, for lack of a better term, combination key bindings. For example, I was having an issue with ⌘+s. VSCode gave a message that it was waiting for the second key binding. After looking at the keybindings.json, I noticed I had a key binding for opening up user snippets as
{
"key": "cmd+s cmd+n",
"command": "workbench.action.openSnippets"
}
The ⌘+s portion of this key binding conflicted with the default ⌘+s

How to execute snippet instantaneously - vscode

Is there the option to "execute snippets" right away in vscode, meaning without having to press tab? This is really the only thing holding me back from vscode because in vim I can simply configure it, so e.g. if I have a snippet which gets triggered if I type test it automatically replaces test by the snippet content without having to press any extra key like tab. Is this possible in vscode?

Visual Studio Code: How not to show suggestions on space?

So anytime I type space it brings up suggestions, which causes problems when I type space at the end of a line (just because i like having a little space there. This way cursor is at some distance from code when i click at the end of a line, it's easier to see code, it's less cluttered), and press enter. It brings up suggestions menu and insert the first thing from there, while i just want to insert a new line character.
I also need it to show suggestions when I'm typing, but only when I type a non whitespace character, so I can't set it to not bring up suggestions on typing.
I also want to accept suggestions on enter, so I can't turn this off either.
So I'm stuck with wanting suggestions on typing, but not on space, is there a way to somehow exclude space from suggestion triggers?
You can customize how you want to display it, this feature is called IntelliSense.
Go to File > Preferences > Keyboard Shortcuts (MacOs Code > Preferences > Keyboard Shortcuts)
and you can set the new key on:
list.toggleExpand
notification.toggle
if you want advance settings, go to keybindings.json
more info:
https://code.visualstudio.com/docs/editor/intellisense
https://code.visualstudio.com/docs/getstarted/keybindings
I think i've found a solution: turn off Suggest on Trigger Characters option.
This way it doesn't bring up IntelliSense on space or dot or anything else, but it still brings it up when i'm typing ordinary characters