Using Visual Studio Code what is the procedure to:
Remap a built in command's keyboard shortcut. For example, say, Open File (default is Ctrl + O , it's unlikely that anyone would actually change this, but the same process should probably apply for any built in shortcut).
Remap an extension command's keyboard shortcut, say the Bookmark extension's toggle-bookmark (default Ctrl + Alt + K )
IN 2015, this involved editing configuration JSON files, but I don't know which one, or how. In 2021 there's a new UI, how do I find it?
Click File -> Preferences -> Keyboard shortcuts. Use the tab that opens up to edit and find available key bindings and assign them.
Historical Note: In very early versions of visual studio code, you would Click File -> Preferences -> Keyboard shortcuts and you would get JSON like this keybindings.json
:
// Place your key bindings in this file to overwrite the defaults
[
{ "key": "ctrl+o", "command": "workbench.action.files.openFile" },
{ "key": "ctrl+alt+k", "command": "bookmarks.toggle",
"when": "editorTextFocus" }
]
But now in 2021 versions, there is a proper GUI, which is great because the json editing method was error prone and hard to discover.
The json editor feature has been moved to a new icon:
If you want to change the advance settings of keyboard shortcut such as when
then you can follow these steps:
Update: (Thanks @phdoerfler for pointing it out that icon has changed)
File->Preferences->Keyboard Shortcuts Click on icon on top right corner that says "Open Keyboard Shortcuts(JSON)" to open JSON version and place the keybinding.
You can find this in Documentation here .
%UserProfile%\\AppData\\Roaming\\Code\\User\\keybindings.json
file Keep in mind you can type things like shift ctrl c
in the Search input in Keyboard Shortcuts panel to find commands by their keybindings.
Here you can find documentation which among other stuff contains also information about what When
conditions you can use.
The latest version of Visual Studio Code 1.11.0 provides a rich and easy keyboard shortcuts editing experience using a new Keyboard Shortcuts editor. Read more here on their website.
I will not repeat others answers! And if like me! You get to install a mapping extension!
My prefered is Visual studio keys map
And the question would have been how you select it! How you change it ! Can we install multiples! And select between them!
First here some useful links about key binding and shortcuts
https://code.visualstudio.com/docs/getstarted/keybindings
https://code.visualstudio.com/docs/getstarted/tips-and-tricks
And before any, know that you can get to the keymaps extension by using the bottom left settings button for settings context menu! As in the picture bellow:
or through file>Preferences>keymap
Then you have to install one of the keymaps
The thing to know is that it will take place and make the changes right away !
The new one take over! Or some mix! I couldn't tell! And you may have problems!
Remove the old ! remove the new one! And install it again! That's the way that i found it works! Disabling and reenabling didn't work!
And better always let only one installed at a time!
Unfortunitly as by Now 2020-05-08 no options to select between keys mapping exist!
Just remove! You may need to restart the editor!
Also note that if you uninstalled all and reinstalled the one you want! And changes didn't take place! Close the editor and reopen it ! That's help!
I hope that's help and may be save you some searching time!
And sure in the future we will have better handling! As vscode is just keeping getting more awesome and awesome! So an option to select and better handling will is expected to be added! And we will wait for it!
open keyboard shortcut
in the search bar(For extra info follow from 4th point)
open keyboard shortcuts (JSON)
(Refer to the image)I tried
{
"key": "ctrl+a",
"command": "workbench.action.terminal.selectAll",
"when": "terminalFocus && !isMac"
}
by this now I can select all in vscode terminal
FYI on mac the keybindings.json file sits there:
/Users/your_user_name/Library/Application Support/Code/User/keybindings.json
On Windows: Ctrl + K , then S
On Mac: ⌘ + K then ⌘ + S
This opens Keyboard Shortcuts Editor. It's searchable/filterable by either shortcut name or the key combination itself (example: type "ctrl" to see all bindings to the CTRL key.)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.