How to transfer VSCode key mapping on windows to u

2020-07-02 09:59发布

I use vs-code as my go-to editor on Windows. Recently I've installed on Ubuntu and now the default key mapping is different.

Is there any way I can set the key mapping on Ubuntu similar to what they were for Windows, or at least a subset of it?

5条回答
叛逆
2楼-- · 2020-07-02 10:36

A quick way to transfer the default keymap without an extension:

VS Code Windows (source)

  • open "Show All Commands" / Ctrl+Shift+P
  • select Open Default Keyboard Shortcuts (JSON) (docs)

    enter image description here

    Note: @Ville Venäläinen's answer did not work for me for default key bindings.

  • copy everthing to clipboard or a temporary file (like you need it)

VS Code Linux (target)

  • open user keybindings / CTRL + K CTRL + S → click Open Keyboard Shortcuts (JSON) button

    enter image description here

  • paste all previously copied settings to this file. If you already have custom user settings, make sure to don't overwrite them. Also preserve the file JSON structure [{}, {}, ...].


Additional notes

You can make a backup of the keymaps before. Default file locations analogue to settings.json:

Linux: $HOME/.config/Code/User/keybindings.json
Windows: %APPDATA%\Code\User\keybindings.json

If needed, also copy custom user keyboard shortcuts in source and append them in the target keybindings.json file (as explained above).

This worked well for me with a Debian target distro. If you should happen to get a key conflict, just delete or change the relevant key binding for this case.

查看更多
何必那么认真
3楼-- · 2020-07-02 10:36

I personally use the code-settings-sync extension.

Synchronize Settings, Snippets, Themes, File Icons, Launch, Keybindings, Workspaces and Extensions Across Multiple Machines Using GitHub Gist.

查看更多
相关推荐>>
4楼-- · 2020-07-02 10:40

I have created an extension that provides the default Windows keybindings. It is on the VSCode extension marketplace and called Windows Default Keybindngs.

I have tested it on Linux with VSCode 1.38.0 and 1.36.1.

The new bindings take precedence where there is a conflict, but existing, non-conflicting bindings are still available.

Basically all I did was use HolyBlackCat's suggestion to run "Preferences: Open Default Keyboard Shortcuts (JSON)" and stuff the result into the appropriate place in package.json. (Plus document it and figure out how to publish it!)

Update 2020-06-05: In response to a question in a comment, I did a search and found LinuxKeybindings, an extension that provides the default Linux bindings. I have not tried it myself but this could be useful for those wanting the Linux bindings instead of Windows bindings.

查看更多
Lonely孤独者°
5楼-- · 2020-07-02 10:44

At least with the latest VSCode, you can go to File -> Preferences -> Keyboard Shortcuts. On that page, there is a text under the search field: For advanced customizations open and edit keybindings.json. That will open you a view showing the default keybindings on the left and an empty file on the right for your own bindings. You can try to copy those bindings from Windows and save the to your Ubuntu one.

查看更多
够拽才男人
6楼-- · 2020-07-02 10:51

If you're not customizing your keymap, look through VSCode Keymaps for keymaps and install on both Windows and Ubuntu.

查看更多
登录 后发表回答