Is there a shortcut for vscode's command center? - visual-studio-code

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.

Related

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 do I trigger suggestion(s) in VSCode in Catalina?

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

Visual Studio Code - Shortcut - Collapse all files in explorer

Can you anyone provide the shortcut for collapse all files in visual studio code explorer?
I personally prefer not to create new shortcuts. As #Mark pointed out on the answer of #JayChase there is an existing shortcut, but it requires the explorer to be in focus. Therefore I combine the shortcut mentioned by #JayChase with another standard shortcut, to get the desired behaviour.
command + 0 (focusses on explorer).
command + left-arrow
An additional benefit over this approach is that I usually want to focus on the explorer view if I want to collapse the folders.
Open the Keyboard Shortcut by pressing Ctrl + K then Ctrl + S and search for Collapse, you will see the Collapse Folders in Explorer key binding (It is empty by default). Press the + button to add your desired key binding.
Now you can enjoy your shortcut.
it's cmd/ctrl + shift + up-arrow
You can collapse all folders using cmd/ctrl left-arrow.
First, click anywhere in the explorer window to activate it, then use the shortcut.
On Windows and Linux.
Ctrl + Left arrow
On Mac:
⌘ + Left arrow
When the Explorer is active, you could use the Workbench list based shortcuts. list based shortcuts include collapse, collapse all, expand, expand all, toggle expand/collapse
To see what are the shortcuts open Keyboard Shorcuts -> Search for list. . Here you find shortcuts for collapse, collapse all, expand, expand all, toggle expand/collapse. These shortcuts work when the Explorer is active, as the Explorer works as a list.
Below is a screenshot for Mac.
If you would like to define a shortcut, without activating the Explorer, then I would recommend - cmd+k ctrl+c. You could add this by opening Keyboard Shorcuts -> Search for Collapse Folders in Explorer -> Click the edit button after hovering over the the Command you want to edit.

How to close the search toggle for vscode?

This is an extremely stupid question... but how do I close/toggle the search box in vscode?
I hit [ cmd + shift + f ] to do a global search, but then I need to reach for my mouse to actually close the box to allow for more screen space.
I've searched through their issues, and there seems to be another user in the past who also experienced something similar --> https://github.com/Microsoft/vscode/issues/32613 , but the solution provided of cmd - b only works for closing the sidebar.
My developer speed has drastically dropped since this issue, and I'm certain there's been a fix.
Please help. :(
**added in picture here -->
Press CTRL + SHIFT + E. It will switch to and focus the explorer.
Your search results are appearing in the panel, not the sidebar.
To toggle the panel:
pc/mac: ctrl + ` (backtick)
mac: ⌘ + J
However, if you want your search results to appear in the sidebar (which I think is the default behavior), then add this line to your settings:
"search.location": "sidebar"
Similar to what Vijey has mentioned, you can use the Toggle Panel keyboard shortcut which will do the job for me. On A mac the shortcut is
⌘ Command+J
I'm coming from sublime where the search results appear in a new tab - making it much easier to close the results (just like closing an other tab)
The best way to get rid of the search panel is by doing the following: -
On a windows computer, press and hold CTRL + Q
A window will then pop up, you can then release Q when the window pops up but you still have to hold down the CTRL key to keep the pop up open
3.Now use your mouse to click on the option called explorer and the search menu is now gone
There is no keyboard shortcut to close the search panel. However, you can create a shortcut yourself as shown in the attached image.
1) Go to File > Preferences > Keyboard Shortcuts.
2) Search for the command 'Close Panel' and set it to your convenient keyboard shortcut.
In the image below, I set it to Ctrl+F8.
If the search box displays in the sidebar (see Amr Noman's answer on how to set that up if it isn't already), How do you close the search box and go back to your project folders? In this case, there is no tab you can close with a click of the mouse. One way is to set up a keymap shortcut, e.g.
{
"key": "cmd+'",
"command": "workbench.files.action.showActiveFileInExplorer"
},
You can figure this out by going to Preferences -> Keyboard Shortcuts and searching for sidebar. One of the hits is described as "File: Reveal Active File in Side Bar"
More generally, any action that hides your project folder view in the sidebar can be cancelled by this shortcut.

Open current editing file in explorer tree

I'm wondering if there is a shortcut for VS Code that highlights in solution explorer tree current opened file. Like we have in Visual Studio:
Alt + Shift + L
Couldn't live with no complete answer, so figured out the following:
Without a direct keyboard shortcut:
Open the command palette via Cmd-Shift-P (or Cmd+P then >) and type Files: Reveal Active File in Side Bar.
This reveals the active file in the side bar similar to Visual Studio's Alt+Shift+L
Then, take the above and map a keyboard shortcut to it:
Open keyboard shortcut preferences file via Cmd-Shift-P followed by Preferences: Open Keyboard Preferences File.
Add in the following (taking Visual Studio's lead, I've personally mapped it to Alt+Shift+L, but map to what you want).
// Place your key bindings in this file to overwrite the defaults
[
{
"key": "shift+alt+l",
"command": "workbench.files.action.showActiveFileInExplorer",
},
]
Note that it's not as good as Visual Studio, Atom, etc. in that you can't then navigate with arrow keys in the tree (arrow keys navigate the active file contents), but I guess I'll eventually figure out how to do that.
#Tomoyuki Aota points out that you can do the following to navigate with arrow keys:
After Files: Reveal Active File in Side Bar, press Ctrl+Shift+E (Show
Explorer). After that, I can navigate the files in the explorer by the
arrow keys.
I don't think there's a command for that, but there is a shortcut to enable/disable revealing the current file as you open it:
"explorer.autoReveal": true
Try this:
Together with #Rob's correct answer:
"explorer.autoReveal": true
then Ctrl-Shift-E (Show explorer) focuses that file in the explorer and the arrow keys will navigate up/down/left/right like any list. This works even if the explorer is closed prior to the Ctrl-Shift-E.
Ctrl-Shift-E has the added bonus in that it will toggle focus between the highlighted file and its editor as well.
For mac, use Cmd-Shift-E
Right-click the file tab (not necessarily current one) and click "Reveal in Side Bar".
I was able to achieve this by customizing the workbench.files.action.focusFilesExplorer command with keybinding Alt + shift + L
Open the Keyboard Shortcuts ctrl + K + shift + S
search for focusFilesExplorer command & customize
Provide your keybindings that you are used to - I set mine to Alt + Shift + L
F1 then type "reveal" also works from in VS Code, at least for me.
It looks like the actual version of VS Code offers a command for this feature now.
In the settings, type revealInExplorer in the search bar to find the command. There is no default keybinding, so just put your own. Works like a charm!
Download the open in browser extension, that's it.
Right click > Open in primary/secondary browser function appears, and the ALT+B / ALT+SHIFT+B shortcuts become available.
Had a similar case and ended up here looking for help.
I opened a file in "preview" mode after clicking a link in a .md file and wanted to know where this opened file was located in the project.
I found this button in the upper right corner of VS Code which was exactly what I wanted:
It's called "show source"
Also check "Explorer: Auto Reveal Exclude" patterns in VS Code settings. Files that fit any of the patterns will not be auto revealed in the Explorer tree.