简体   繁体   中英

How to reset Visual Studio Code key bindings?

I have been experimenting with my vs-code key bindings.

I would like to reset the key-bindings to the original settings.

How do I do that?

I am on Linux Mint 18.

I tried removing all the records from the keybindings.json

Version 1.34.0 seems to have the settings at a slightly different location:

  1. Click File > Preferences > Keyboard Shortcuts
  2. There is a triple-dot (...) at the top-right hand corner. Click on that and select "Show User Keybindings"
  3. Delete your listed keybindings

Here are the steps to reset the keybindings in VS code.

  1. Click File > Preferences > Keyboard Shortcuts or Press Ctrl+K Ctrl+S

在此处输入图片说明

  1. Then, click on keybindings.json

在此处输入图片说明

  1. From keybindings.json remove the custom bindings you want to reset.

It seems newer versions of VSCode (>1.33 for Mac) doesn't have a direct link to keybindings.json anymore, as this answer shows . However, there is an option to reset user defined keybindings without mess with files.

Go to the Keyboard shortcuts settings:

在此处输入图片说明

There, find the setting tagged as "User". If you click on it with the right mouse button, a context menu will show the option "Reset Keybinding":

在此处输入图片说明

This action is gonna reset the selected keybinding and tag it with "Default" again.

first go file > preferences > keyboard shortcuts
you can see all key that you change whit click on triple-dot or put ( @source:user ) in search bar
now you can right click on which one that you want to reset and select ( reset keybinding ) 在此处输入图片说明

If you had installed the Keybinding as an Extension eg Sublime or IntelliJ IDEA Keybindings, simple go to Extension and disable or uninstall it and you would have your default keybinding.

在此处输入图片说明

Try this documentation page about key binding in VSCode: https://code.visualstudio.com/docs/getstarted/keybindings

Open a directory that contains user settings ( https://code.visualstudio.com/docs/getstarted/settings ) and try to remove user key bindings file.

For future searchers, since this question refers to Linux, even if the keybindings.json file is moved again one can always just use locate to find it: $ locate keybindings.json .

Chances are, you will only have one, and if you have more, it will be clear where it is, as it is somewhere inside Code folder.
For example, as of today, mine is here: /home/neex/.config/Code/User/keybindings.json

Going directly to the file, will give you the opportunity to keep what you want and remove what you think might be the problematic setting.

On VS Code version 1.42.1 on Mac you can find a button that opens the Keyboard shortcuts JSON file on the top right corner of the keyboard shortcuts screen which you can open from Code -> Preferences -> Keyboard Shortcuts

在此处输入图片说明

For the newer version of VSCode (Version: 1.43.1), you can open the keybindings.json file from the Command Palette ( ⇧⌘P OR Ctrl+Shift+P ) with the Preferences: Open Keyboard Shortcuts (JSON) command.

Once you delete all the data in the keybindings.json file you should get rid of any changes you made to keyboard shortcuts for your installation. Everything would be set back to default.

Reason: The first line in keybindings.json file is a comment // Place your key bindings in this file to override the defaultsauto[] , which means if you delete all what is there you'll get the VSCode defaults. (Ref https://code.visualstudio.com/docs/getstarted/keybindings#_advanced-customization )

You can find all information on keybindings here .

Do we need another answer? Maybe not, but every year or so I find myself sifting through the information on this page, so to make it quicker next time, here are some notes:

To find the location of the settings, you can look for a button/link to the json file located somewhere in Preferences. However, I have found it easier to find the json files on my hard drive than to locate that button/link inside the app (some users report that the button/link is missing in some versions of the app). If your OS does not allow you to search through system files, open a terminal session and type $ locate keybindings.json .

If you can memorize shortcuts, a typical default shortcut that can take you to the button/link is CMD+SHIFT+P . This shortcut opens a box below the main toolbar and you can type " json " in that box to find a button/link to the json file.

General settings are in settings.json

Keyboard settings are in keybindings.json

MacOS: ~/Library/Application Support/Code/User/

Example of keybindings.json

// Place your key bindings in this file to override the defaultsauto[]
[
    {
        "key": "cmd+r cmd+r",
        "command": "workbench.action.reloadWindow",
        "when": "isDevelopment"
    },
    {
        "key": "cmd+r",
        "command": "-workbench.action.reloadWindow",
        "when": "isDevelopment"
    },
    {
        "key": "shift+cmd+c shift+cmd+c",
        "command": "workbench.action.terminal.openNativeConsole",
        "when": "!terminalFocus"
    },
    {
        "key": "shift+cmd+c",
        "command": "-workbench.action.terminal.openNativeConsole",
        "when": "!terminalFocus"
    },
    {
        "key": "ctrl+cmd+c",
        "command": "editor.action.commentLine",
        "when": "editorTextFocus && !editorReadonly"
    },
    {
        "key": "ctrl+shift+alt+cmd+[Minus]",
        "command": "-editor.action.commentLine",
        "when": "editorTextFocus && !editorReadonly"
    },
    {
        "key": "shift+cmd+c",
        "command": "editor.action.blockComment",
        "when": "editorTextFocus && !editorReadonly"
    },
    {
        "key": "shift+alt+a",
        "command": "-editor.action.blockComment",
        "when": "editorTextFocus && !editorReadonly"
    }
]

Note that mapping a key combination that is already in use may result in conflicts. So the best approach is to first remap that default binding to something else. In the above, for instance, the "-" that prefixes "-editor.action.blockComment" serves to suppress the default binding. Thus, you may find that your key bindings are best set in pairs (unless your preferred combinations are sufficiently rare).

Example of settings.json

{
    "workbench.colorTheme": "Solarized Light",
    "window.zoomLevel": 4,
    "workbench.activityBar.visible": false,
    "workbench.statusBar.visible": false,
    "editor.quickSuggestions": false,
    "editor.suggest.snippetsPreventQuickSuggestions": false,
    "editor.acceptSuggestionOnCommitCharacter": false
}

For VSCode Version 1.35.1, which I'm using, one can directly open the keybindings.json file using the button that looks like {} on top-right corner of "Keyboard Shortcuts" Tab's title bar:

Picture showing {} button in top-right corner

Cleaning content of this file cleans all user defined key bindings.

In the latest version, the setting json file is with highlighted button.

I deleted everything in there and it seems to reset all keys. User setting file

If you are on a Mac, press and hold command while hitting the k and s keys. Then click the icon on the top right with the three circles and press "Show User Keybindings". Then, hit command + delete while highlighting over the keybinding you want to delete.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM