Add platform detect functions in keybindings.json for `when` field
- 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"
}
]
+1
@Treri Is VSCode reading from keybindings.osx.json file directly? Or you have to rename it manually to keybindings.json on OSX?
@mucsi96 I just soft link keybindings.osx.json to keybindings.json
I see.Thanks @Treri
@alexandrudima Aren't those already available? https://code.visualstudio.com/docs/getstarted/keybindings#_when-clause-contexts
isMac
isLinux
isWindows
/duplicate
I'll just slowly close this.
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!