Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to use windows keymap on MacOS #27385

Open
kasecato opened this issue May 28, 2017 · 26 comments
Open

Add option to use windows keymap on MacOS #27385

kasecato opened this issue May 28, 2017 · 26 comments
Labels
feature-request Request for new features or functionality keybindings VS Code keybinding issues
Milestone

Comments

@kasecato
Copy link
Contributor

  • VSCode Version: 1.12.2
  • OS Version: macOS Sierra

We can write keybindings in package.json (Extension Manifest File).

"keybindings": [
    {
        "win": "ctrl+y",
        "mac": "cmd+backspace",
        "linux": "ctrl+y",
        "command": "editor.action.deleteLines",
        "when": "editorTextFocus && !editorReadonly"
    }
]

I got a request from some developers that they are using macOS but they want to use Windows keybindings. See Add option to use windows keymap on MacOS.

So, I'd like to switch mac and win in settings.json or something. Can I do this?

@roblourens roblourens added feature-request Request for new features or functionality keybindings VS Code keybinding issues labels May 28, 2017
@alexdima alexdima added this to the Backlog milestone May 29, 2017
@alexdima alexdima removed their assignment May 29, 2017
@richardpeh
Copy link

Bump

@sumitgpt
Copy link

sumitgpt commented Sep 3, 2017

I too want this

@Syeberman
Copy link

Bump

@rrousselGit
Copy link

I'd like this feature as well for the same reasons.

I can contribute. But I don't know where to get started. @alexandrudima @roblourens any guidance on where to start things ?

@mredbishop
Copy link

Yes, this feature would be really useful for us too. We are predominantly a Linux studio but we do use OSX for some dev work. It would be great when using OSX we could have the Linux key bindings if possible?

@petermetz
Copy link

As an extension to this: should also work the other direction. ;-)

@festum
Copy link

festum commented Mar 20, 2019

Waited for 2 years. I only have to overwrite windows keymap on mac keymap setting.

@shynome
Copy link

shynome commented Jul 24, 2019

Add option to use windows keymap on Linux

@mredbishop
Copy link

mredbishop commented Sep 2, 2019

Still need to be able to switch to the defaults for another OS. This would be especially useful now as a number of us have started using WSL 2 due to the performance improvements over WSL 1 but we have trained our brains on the Linux key mappings :o)

Is there somewhere you can get the other OS keymaps to just overwrite the current one manually?

@chaptergy
Copy link

I would also love this, as I use Linux for work and Windows on my private machine. This could also be implemented as an extension or multiple ones on the marketplace.

@jhoffmanmixmax
Copy link

I also need this pretty bad

@CultivateCreate
Copy link

Yes. I just synced my parallels version of vscode to the settings I uploaded from my mac, and now It's completely unusable.

PLEASE implement the 'super' key as seen in Sublime.

@philpowers
Copy link

Lack of this functionality basically makes VSCode a non-starter for me on the Mac... My Mac sits right next to my PC, and if I have to memorize two sets of key bindings, I might as well stay in Xcode all the time (which makes me sad).

@MichaelMakesGames
Copy link

I also would really like this functionality, as a switch back and forth between a Mac at work and Linux at home.

I looked into the code a bit, and had some luck hardcoding some OS values, but I was getting some weird behavior. We would also want a final version of this to be configurable in the preferences/settings. Unfortunately it looked like a lot of this OS stuff is happening at too low of a level to have access to the configurationService. I'm not familiar with the vscode code base, so I might be wrong about some of this, but this at least doesn't seem like a beginner-friendly issue to fix.

I did find a potential work-around though. There's a "Preferences: Open Default Keyboard Shortcuts (JSON)" command which opens a readonly editor with all of your current OS's shortcuts. You can copy the contents of that file and then use "Preferences: Open Keyboard Shortcuts" on your other computer to open your user-defined shortcuts and paste in the other OS's defaults. You could also do that on one computer and then sync your settings. I'll try that out this weekend and see how it goes.

@FredHappyface
Copy link

I've created a few extensions that should help with this. Though it would certainly be preferable to have this functionality out of the box

ext install fredhappyface.windowskeybindings
ext install fredhappyface.linuxkeybindings

Note that some keybindings may interfere with other extensions. In that case drop an issue and I'll try and fix asap

@ucavalcante
Copy link

Same Request for linux, will be great if we can chose the main keymap theme on preferences, im current migrating from windows dev environment for linux and need to learn everything again.

@UniverseFly
Copy link

Same request for Mac. I'm a frequent Mac user but sometimes would be using Windows when I wanna stick to my muscle memory for Mac.

@juanjoe33
Copy link

Any news about this? I feel so lose working with VSC on Windows...

@duck-dev-go
Copy link

I would also like this feature

@prantlf
Copy link

prantlf commented Aug 2, 2022

You could use the clause contexts isLinux, isMac, isWindows and isWeb as a workaround. For example:

"keybindings": [
  {
    "command": "editor.action.deleteLines",
    "key": "cmd+backspace",
    "when": "isMac && editorTextFocus && !editorReadonly"
  },
  {
    "command": "editor.action.deleteLines",
    "key": "ctrl+y",
    "when": "!isMac && editorTextFocus && !editorReadonly"
  }
]

But your suggestion with the property mac will work too. Just use key instead of win:

"keybindings": [
  {
    "command": "editor.action.deleteLines",
    "key": "ctrl+y",
    "mac": "cmd+backspace",
    "when": "isMac && editorTextFocus && !editorReadonly"
  }
]

@mogelbrod
Copy link

mogelbrod commented Nov 5, 2022

After working on vscode extensions I too discovered the ability to define platform-specific bindings and immediately went and replaced all the duplicated bindings I had in keybidings.json. I was rather surprised (and disappointed) when I discovered that they didn't work 🙁 Having support for { "key": "...", "mac": "...", "win": "...", "linux": "..." } would remove the need to define and maintain otherwise identical mappings that only differ by the key prop as well as including "when": "isX && ...". Maintaining these are error prone, and result in 2-4 times as many bindings having to be added and updated anytime one wants to change the command or when clause.

It's too bad a PR that implemented this was closed in favour of #54894

Example of verbose double mapping required today (note that multiple isMac checks are necessary):

[
  {
    "key": "cmd+w",
    "command": "workbench.action.terminal.kill",
    "when": "terminalFocus && terminalHasBeenCreated || terminalFocus && terminalProcessSupported"
  },
  {
    "key": "ctrl+w",
    "command": "workbench.action.terminal.kill",
    "when": "!isMac && terminalFocus && terminalHasBeenCreated || !isMac && terminalFocus && terminalProcessSupported"
  },
]

My personal keybindings.json has ~40 of these mappings, which makes it much harder to maintain and organize them.
Compare this to the equivalent binding that the proposal would enable:

[
  {
    "key": "ctrl+w",
    "mac": "cmd+w",
    "command": "workbench.action.terminal.kill",
    "when": "terminalFocus && terminalHasBeenCreated || terminalFocus && terminalProcessSupported"
  },
]

@editicalu
Copy link

While this doesn't solve the design issue in vscode, there's an extension to (partially) solve the issue. Leaving it here as it might be useful for people having the same frustrations.
https://marketplace.visualstudio.com/items?itemName=smcpeak.default-keys-windows

@cheyngoodman
Copy link

I'm using a Mac keyboard on both MacOS and Linux. Rebinding keybinds works for most things.

I can't find a way to rebind Ctrl + Click for opening links to command + Click to open links.

@kaiwu-astro
Copy link

2024 - 2017 = 7 years!
Microsoft guys never use multiple OS?

@fMoro1999
Copy link

@kaiwu-astro, plot twist: Microsoft devs work using MacBooks 💀

@marcospgp
Copy link

marcospgp commented May 8, 2024

I wanted to make keybinds on Windows the same as MacOS, and got most of the way there using PowerToys:

Emulate MacOS keyboard shortcuts

To emulate MacOS keyboard shortcuts on Windows, use the PowerToys Keyboard Manager with the following settings:

(note that replacing left alt and left ctrl should be good enough, but to keep things short "left" is omitted from these key names below. "left" on its own means "left arrow key".)

Remap keys:

  • alt -> ctrl
  • ctrl -> alt

Remap shortcuts:

(note that the key remap above applies first, so alt below represents the ctrl key on the keyboard, and vice versa)

Restore switching between windows with alt + tab after key remap:

  • ctrl + tab -> alt + tab

Restore switching tabs:

  • alt + tab -> ctrl + tab
  • alt + shift + tab -> ctrl + shift + tab

Move cursor to start/end of line (does not seem to require additional entries for selecting text with the addition of the shift key):

  • ctrl + left -> Home
  • ctrl + right -> End

Move cursor word by word, also selecting text if shift included:

  • win + left -> ctrl + left
  • win + right -> ctrl + right
  • win + shift + left -> ctrl + shift + left
  • win + shift + right -> ctrl + shift + right

Erase word by word:

  • win + backspace -> ctrl + backspace

Drag text lines up and down:

  • win + up -> alt + up
  • win + down -> alt + down

Missing:

  • Erase to start of line (cmd + backspace on MacOS) (not very important as one can simply select the line, then erase.)

  • Some VSCode keybinds are the same between Windows and MacOS, and this remap will break them if they use ctrl or alt, so they need to be restored - such as with "toggle terminal" (JSON generated by VSCode after modifying keybind):

      {
        "key": "alt+oem_3",
        "command": "workbench.action.terminal.toggleTerminal",
        "when": "terminal.active"
      },
      {
        "key": "ctrl+oem_3",
        "command": "-workbench.action.terminal.toggleTerminal",
        "when": "terminal.active"
      }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request for new features or functionality keybindings VS Code keybinding issues
Projects
None yet
Development

No branches or pull requests