0
{
    "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);
Mark
  • 143,421
  • 24
  • 428
  • 436
Imtiaze
  • 43
  • 9

1 Answers1

1

use the when clause in the keybinding

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

don't call your JavaScript file: javascript.json

rioV8
  • 24,506
  • 3
  • 32
  • 49
  • Thank you for your answer. But the point is I need it in a new line. `var fruit = 'mango'; // it will remain as it is console.log(fruit); // new line` – Imtiaze Jul 25 '22 at 17:36
  • @Imtiaze then add `\n\t` in your snippet – rioV8 Jul 25 '22 at 20:22