How do I trigger suggestion(s) in VSCode in Catalina? - visual-studio-code

This tells me that I could use ⌃ + Space combination in order to display suggestions for my code. However, ctrl + Space ( ^ key is ctrl as far as I know) only seems to change the input language keyboard in my system. Nothing else seems to work.

Try Option + Escape, on mac.
The mac keyboard shortcut ctrl + space for switching input sources overrides the VSCode one. Because of this, VSCode added a new keybinding just for mac, Option + Escape
This is actually called intellisense, and the new keyboard shortcut was added in the November 2019 update.

You can disable the macOS shortcut in System Preferences → Keyboard → Shortcuts.
Alternatively you can set up a custom keybinding for this command in VS Code, so that it no longer conflicts with your system shortcut. Please refer to the official documentation.

Recently, ⌘I (i.e. command + i) is also a by default key binding for triggering suggestions.

On MacOS Ventura,
Go to System Settings
Select Keyboard on the Left panel
Select "Keyboard Shortcuts"
Select Input Sources and toggle the switch labelled "Select the previous input source".
Quit vscode and relaunch

Related

Is there a shortcut for vscode's command center?

Vscode just introduced a new experimental command center feature.
Is there a shortcut for starting the command center's "Show Search Mode..."
You can replace the normal title bar with the Command Center search box by enabling the VSCODE window.commandCenter setting. To enable this setting, navigate to File>Preferences>Settings, search for "commandcenter" and select the CommandCenter option. Note the caveat that the option changes the TitleBarStyle, which replaces the menu pulldowns (File, Edit ...) with a menu icon to access the menus.
See
https://code.visualstudio.com/updates/v1_69#_command-center
There does not appear to be a dedicated keyboard shortcut for this as of now. Considering it is experimental, it very well could be added. The closest thing I've found was performing a "Go to File" shortcut and then typing ?.
Thus, on Windows, Ctrl + P, ?.
Ctrl + P opens the dropdown, and then the ? opens the Search Modes.
I do used to open the command dialog using cmd+shift+p and there you can have the command center as your first choice.

VSCode Command Palette (Ctrl + Shift + P) keyboard shortcut isn't working on new installation

When I press Ctrl + Shift + P in VSCode (shortcut for "Command Palette") nothing happens.
Side note: I've just installed VSCode on my new PC (Windows 10,) so it's a fresh installation if that helps (it works on my laptop.) This is unsettling since I can actually see Ctrl + Shift + P listed in the bindings table.
It's important! Since for the most part I use this command to habitually open files.
Now I understand it can be possibly caused by some other software, perhaps -- I'm looking into that (will post what I find, if I ever get it to work.)
If I can't figure it out, I'm simply going to rewire it (at least for now) in key bindings but it's not really what I want to do.
Meanwhile, is there any classic cases that can jam Command Palette, specific to new installation?
This is an actual issue on GitHub There is a good chance it's caused by other software which may be something like:
Password keychains
Screen capture
OBS
(Check any similar software you might use I can almost guarantee that one of the other apps is intercepting it globally. You said it's a new installation, so you probably installed other apps.)
To see all shortcuts or rebind Ctrl + S, then K as per this edit keyboard shortcuts tutorial. Make sure Ctrl+Shift+P is on this list. Another issue that could cause this is your VSCode json settings file is read only or doesn't exist for some reason. A lot less likely, but still worth checking. Good luck with this.
Razer Cortex after the last update started to intercept Ctrl + Shift + P and other keybindings. I've turned it off and it helps, but you can try to change those keybindings in the Cortex settings if that's what causing the problem in your case.
it would be "ctrl + k + s" to see the command list, and yes F1 is the alternative to "Ctrl+shift+P" I also have Razer mouse and it seems to conflict.
For Mac Users
In Mac had the same problem and realized that it occures after triggering Git Lense extention. A quick inspection on key bindings and disabling the non-default binding there solved the problem.
For me, TickTick on the Mac had overtaken the Command+Shift+P. I disabled it in TickTick -> More -> Hotkeys and removing the global shortcut.
A more general way to remove conflicting shortcuts on MacOS:
choose Apple menu > System settings, then click Keyboard in the sidebar. (You may need to scroll down.)
Click Keyboard Shortcuts on the right. A warning icon appears next to conflicting keyboard shortcuts. Double-click the shortcut, then change it.

How do I turn off text formatting on save in visual studio code?

I don't know why my code is auto formatted on save and for some reason changing the layout. I figured out this was due to auto format on save. How do I turn auto save off in Visual Studio Code?
For Windows:
Here are the some basics steps to be followed to turn off auto complete.
Step:1 - Press Ctrl + Shift + P to open Command Palette. Then screen like below image appears.
Step:2 - Type Save without formatting and click the matching option available. It either commands on click or redirects you to next interface.
If it works on click then it's fine and if your are redirected to next screen just uncheck auto format option under onsave. For me it worked on cick to the shown command.
For Mac:
Cmd+K S
This was introduced in back in 2018, the keybinding (on MacOS) is:
Cmd+K S
For keybindings for your own system, search for the command saveWithoutFormatting in the Command Palette
Default: Ctrl + k + Ctrl + Shift + s on 🪟 Windows.
For others having the same problem and if Save without format is inconvenient to do every time and if you want permanent settings for saving without format here are the steps:
Edit the settings.json file. You can do that with the command "Open Settings (JSON)"
press Command + Shift + P (to open the command palette)
and start typing the command "Open Settings (JSON)" and select from the suggestions.
The setting is named formatOnSave and you should set it to false, to disable it. It can be present multiple times for different types of things.
"editor.formatOnSave": false
It is best to search for "OnSave", because there might also be other settings that are doing formatting on Save, for example:
"editor.codeActionsOnSave"
In mac you can save without formatting with the following shortcut, (No need to touch the config):
If you don't want to open the command palette every-time, you can change the Ctrl/Cmd + S shortcut to make the action "Save without Formatting"
and remove the shortcut for "Save".

How to Move a Line Up or Down in Visual Studio Code on Chromebook

I know how to do it on Mac, Linux and Windows, but it doesn't work on Chromebook. You'd expect it to be alt-up/down like Win/Linux, but that is treated like home and end.
Anybody know the trick?
Alt + Up/Down and Ctrl + Alt + Up/Down are reserved by Chromebook. You could open File --> Preferences --> Keyboard Shorcuts in VS Code and change Move Line Up/Down settings to something else.
Chromebook keyboard shortcuts
Chromebook keyboard shortcuts image
There's a easy way.
Just open google-chrome and type chrome://flags in the URL bar,go to the Experiments page.
Search Deprecate Alt based six-pack , then Enable this feature.
Restart.
Then you can use the default shortcut to move line up/down in VSCode.

Ubuntu Visual Studio Code Toggle Comment no respond

I encountered an issue with toggle comment in visual studio code on Ubuntu. Default hot key was "ctrl+/", it didn't respond when I click on a line of code or highlighted the line of code. I changed the hot key to "ctrl+l" under preference -> Keyboard Shortcuts and it didn't respond too.
I tried to google this but nobody seems to encounter this issue or posted this question.
Is there something else I need to enable to make this work?
In my case it was due to the fact that VS Code 'didn't know' the language the file was written in. I was editing a .cmake file and VS Code does not 'understand' CMake syntax when installed out-of-the-box.
Installing a 'CMake' extension enabling CMake syntax highlight also enabled the 'Toggle Line Comment' [Ctrl+/] shortcut to work.
(I'm guessing without the specified language VS Code simply does not know which symbol to use to comment out the lines - e.g. '//' or '#' or else).
This the issue because in ctrl + /
/ -> is numpad divide
or
/-> simple / the key not present in numpad
so if you try any of these combinations one will definitely work, if u want to work with numpad one only you can go to
File-> Preferences -> Keyboard shortcuts (there search for toggle line comment and give your own shortcut)
For me, in VSCode has a error with ctrl + } and ctrl + shift + } 'cause is inversly and no show correctly the keys to hit.
You must redirect to Keyboard Shortcuts - Visual Studio Code, and search the shortcut "Comment", and hit:
blockComment: Insert ctrl + } when you hit ctrl + shift + }.
commentLine: Insert ctrl + shift + } when you hit ctrl + }.
The Shortcuts show like this
I hope that help for you.
That how I solved it. Open File/Preferences/Keyboard Shortcuts or type ctrl+K ctrl+S VSCode preferences. Then click {} button in the top-right corner. In the last version on Sep 16, 2019, it looks like a file with the arrow. Now you see keybindings.json, at the bottom there is a button Define keybindings - click and type in the form there "Ctrl+/" It will show you all commands with your combination. I found and commented the one from Emmet
` {
"key": "ctrl+/",
"command": "editor.emmet.action.toggleComment",
"when": "editorTextFocus && !editorReadonly"
},`
There was a conflict.
I had the same problem and I didn' found the answer in the internet, but eventually I found it on my own.
My system is Linux Mint and my computer is a Thinkpad 440p with an brazilian Portuguese keyboard. This keyboard doesn't have a Right Control key, and then key usually associated with it is used for slash (/) and interrogation mark if pressed with shift. Mint has a good driver for it, mapping it to the correct symbol. I have never had issue with any other code editor or software.
However VSCode by default bypass this keymap done by the system and uses raw code com from keyboard hardware. This can be changed in setting, keyboard dispatch. I change it from "code" to "keymap" and then it worked like a charm.