vscode icon indicating copy to clipboard operation
vscode copied to clipboard

Add platform detect functions in keybindings.json for `when` field

Open ik0r opened this issue 10 years ago • 7 comments

  • VSCode Version: 0.10.11
  • OS Version: OS X 10.11.2

I use vscode both in OS X and Linux. And I want to backup my configs via github. So I can soft link settings.json and keybindings.json to corrent directory.

Suppose I want to map cmd+y(OSX ) or ctrl+y(Linux) to redo in keybindings.json

Now I have to create two files. keybindings.osx.json and keybindings.linux.json. The only difference is in keybindings.osx.json I map cmd+y to redo, and in keybindings.linux.json I map ctrl+y to redo.

Can I mix these configs in just one file keybindings.json, and use platform detect function to decide which map rule work?

Just like below or something else?

[
  {
    "key": "cmd+y",
    "command": "redo",
    "when": "os.isDarwin"
  },
   {
    "key": "ctrl+y",
    "command": "redo",
    "when": "os.isLinux"
  }
]

ik0r avatar Mar 24 '16 09:03 ik0r

+1

mucsi96 avatar Mar 30 '16 07:03 mucsi96

@Treri Is VSCode reading from keybindings.osx.json file directly? Or you have to rename it manually to keybindings.json on OSX?

mucsi96 avatar Mar 30 '16 07:03 mucsi96

@mucsi96 I just soft link keybindings.osx.json to keybindings.json

ik0r avatar Mar 30 '16 07:03 ik0r

I see.Thanks @Treri

mucsi96 avatar Mar 30 '16 08:03 mucsi96

@alexandrudima Aren't those already available? https://code.visualstudio.com/docs/getstarted/keybindings#_when-clause-contexts

isMac
isLinux
isWindows

usernamehw avatar Jan 26 '19 14:01 usernamehw

/duplicate

I'll just slowly close this.

usernamehw avatar Jan 28 '19 23:01 usernamehw

Thanks for creating this issue! We figured it's covering the same as another one we already have. Thus, we closed this one as a duplicate. You can search for existing issues here. See also our issue reporting guidelines.

Happy Coding!

vscodebot[bot] avatar Jan 28 '19 23:01 vscodebot[bot]