microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
160.7k stars 28.15k forks source link

Add option to use windows keymap on MacOS #27385

Open kasecato opened 7 years ago

kasecato commented 7 years ago

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?

richardpeh commented 7 years ago

Bump

sumitgpt commented 6 years ago

I too want this

Syeberman commented 6 years ago

Bump

rrousselGit commented 6 years ago

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 commented 5 years ago

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 commented 5 years ago

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

festum commented 5 years ago

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

shynome commented 4 years ago

Add option to use windows keymap on Linux

mredbishop commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

I also need this pretty bad

CultivateCreate commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 3 years ago

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 commented 2 years ago

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

duck-dev-go commented 2 years ago

I would also like this feature

prantlf commented 1 year ago

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 commented 1 year ago

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 https://github.com/microsoft/vscode/pull/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 commented 1 year ago

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 commented 1 year ago

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 commented 6 months ago

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

fMoro1999 commented 6 months ago

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

marcospgp commented 2 months ago

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:

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:

Restore switching tabs:

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

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

Erase word by word:

Drag text lines up and down:

Missing: