Skip to content

OS Specific Keybindings #8962

Closed
Closed

Description

I have a company issued OSX machine, linux boxes and windows machines all of which I do dev work on, moving back and forth, I try to keep my settings in sync, it would be very nice to have an operating specific syntax for the keybindings file, much how tasks.json does.

{
    "version": "0.1.0",
    "windows": [
        {
            "key": "win+b",
            "command": "workbench.action.tasks.build"
        },{
            "key": "win+d",
            "command": "workbench.action.tasks.terminate"
        }
    ],
    "osx": [
        {
            "key": "cmd+b",
            "command": "workbench.action.tasks.build"
        },{
            "key": "cmd+d",
            "command": "workbench.action.tasks.terminate"
        }
    ]
}

Or better yet in line with #871 ...

{
    "windows": [
        {
            "key": "win+b",
            "command": [
                "workbench.action.tasks.terminate",
                "workbench.action.tasks.build"
            ]
        },{
            "key": "win+l",
            "command": "workbench.action.tasks.showLog"
        }
    ],
    "osx": [
        {
            "key": "cmd+b",
            "command": [
                "workbench.action.tasks.terminate",
                "workbench.action.tasks.build"
            ]
        },{
            "key": "cmd+l",
            "command": "workbench.action.tasks.showLog"
        }
    ]
}

For that matter it would be wonderful to have this ability for all of the user configurable settings

Activity

  1. alexdima commented on Jul 11, 2016

    @alexdima
    Member

    tasks.json is sitting in the workspace (presumably also checked in a git repo...), thus its need to support different values across different Operating Systems.

    keybindings.json or settings.json are local to the user, since that's where more personal things should stay (i.e. not shared with the team).

    I would personally not complicate the structure for the majority of users that don't need to jump across Operating Systems, I would go for something like keybindings.osx.json, keybindings.linux.json, settings.win.json, etc, which would overimpose the variants without the OS in their filename.

    Benjamin Pasero (@bpasero) Martin Aeschlimann (@aeschli) Johannes Rieken (@jrieken) - You are also heavy cross OS users and share the ownership of the config service. Thoughts?

  2. added
    feature-request
    on Jul 11, 2016
  3. changed the title [-]Operating Specific Keybindings[/-] [+]OS Specific Keybindings[/+] on Aug 14, 2016
  4. alexejk commented on Nov 25, 2016

    @alexejk

    I'm hitting the same issue where I would like to sync my settings cross machines, including Windows and OSX machines. The only thing that currently is not working well for me is keybindings.
    It would be great to provide an option in user-specific keybinds to set "this is only valid for Windows".

    Instead of scoping all of the keybindings, I agree that it makes more sense to allow creation of user-specific keybindings per platform in different files (so besides normal keybindings.json) have something like keybindings.osx.json.

    Just as a thought, another option is introducing a platform property in the keybind itself or ability to have when property handle platform, e.g osWinOnly or !osOSX` or something in this style. But I personally like the idea of platform files.

  5. bjornhanson commented on Aug 21, 2017

    @bjornhanson

    I've been syncing my settings between Linux and OS X and am trying to resolve an issue where I'm loading custom CSS but the path picked up in the settings file by ~/ or $HOME don't seem to point to the same thing on the OS (might have to do with how I'm launching it in Linux). This might be something I can figure out, but in general I could see it being really nice to have any settings setup to be OS-specific, not just key bindings.

  6. repentsinner commented on Jan 25, 2018

    @repentsinner

    We've run into a similar issue with Python .venv support, where the pythonPath differs by OS but is otherwise seems sensible to store in the repo with other things that should be shared.

    {
        // win
        "python.pythonPath": "${workspaceRoot}\\.venv\\Scripts\\python.exe",
        "python.formatting.provider": "yapf"
    }
    
    {
        // mac
        "python.pythonPath": "${workspaceRoot}/.venv/bin/python",
        "python.formatting.provider": "yapf"
    }

    Thanks for considering!

  7. Tyriar commented on Apr 16, 2018

    @Tyriar
    Contributor

    Here's my keybindings.json file, my dotfiles script symlinks that to the correct directory on each platform https://github.com/Tyriar/dotfiles/blob/master/modules/vscode/config/keybindings.json

    Some of the keybindings don't make sense on mac in particular, for example this one which makes ctrl+k a chord on macOS:

    { "key": "ctrl+k ctrl+s",   "command": "workbench.action.openGlobalKeybindingsFile" },

    Something like this would be sufficient for me without complicating the structure:

    { "key": "ctrl+k ctrl+s",   "command": "workbench.action.openGlobalKeybindingsFile",
      "when": "!isMac" },
  8. wavebeem commented on Apr 16, 2018

    @wavebeem
  9. rthomazel commented on Jul 22, 2018

    @rthomazel

    I'd like for this feature to exist as well, mostly to integrate better with windows. I use vscode across Mac, Linux and Windows and my issue is with the git.path setting.

  10. gandalfsaxe commented on Jul 23, 2018

    @gandalfsaxe

    Leaving settings.json as platform agnostic and making os-specific files that can be shared on all OSs for convenience, but only applied on their target platform seems like a good idea.

  11. added a commit that references this issue on Jul 23, 2018
    c521a0a
  12. added a commit that references this issue on Aug 7, 2018
    b9caa37
  13. gandalfsaxe commented on Aug 7, 2018

    @gandalfsaxe

    Good implementation. Thanks!

  14. added
    verification-needed
    on Aug 27, 2018
  15. jrieken commented on Aug 28, 2018

    @jrieken
    Contributor

    verified via code review

  16. added a commit that references this issue on Sep 4, 2018
  17. locked and limited conversation to collaborators on Sep 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

feature-requestkeybindingsverification-neededverified

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions