Home > Enterprise >  Same key binding shortcut use differently in different example.json file in vscode
Same key binding shortcut use differently in different example.json file in vscode

Time:07-26

{
    "key": "ctrl l",
    "command": "editor.action.insertSnippet",
    "when": "editorTextFocus",
    "args": {
        "snippet": "console.log('${TM_SELECTED_TEXT}$1')$2"
    }
}

This just wrap the text into console.log(text);

I need a shortcut or snippet that when I am in the blade.json (laravel) file

$fruit = mango;

when press ctrl l it will insert a new line like

$fruit = mango;
dd($fruid);

And when I am in the javscript.json (js) file the same shortcut (ctrl l) or snippet will insert a new line like

var fruit = 'mango';
console.log(fruit);

CodePudding user response:

use the when clause in the keybinding

"when": "editorTextFocus && editorLangId == 'json'"
"when": "editorTextFocus && editorLangId == 'javascript'"

don't call your JavaScript file: javascript.json

  • Related