Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to edit the default log snippet in VS Code

I'm using VS Code, and there is a default log snippet for JavaScript, that basically adds a console.log() line BUT also adds a new blank line. I want to remove that new blank line. Do you know how to do it? I only can see the way to modify the User snippets, but this snippet was not created by me

like image 904
Broda Noel Avatar asked Jun 12 '18 03:06

Broda Noel


2 Answers

This was slightly answered in other questions but here is my approach anyway. I wasn't able to configure the default snippets in vscode however I created my own snippet and made it at the top of the suggestions.

  1. Go to File -> Preferences -> User Snippets and select JavaScript in order to edit snippets for that language.
  2. Add this entry to the opened file javascript.json and save it
"Print to console": {
          "prefix": "log",
          "scope": "javascript,typescript",
          "body": [
              "console.log('$1')",
          ],
          "description": "Log output to console"
},

then I added

"editor.snippetSuggestions": "top",

in my settings so that it will always be the top suggestion

hope that helps

like image 125
Miguel Acero Avatar answered Mar 11 '23 16:03

Miguel Acero


On my Windows10 machine the log and other default javascript snippets can be found in :

C:\Users\$USER\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\javascript\snippets\javascript.json
like image 45
Filip Van Genck Avatar answered Mar 11 '23 17:03

Filip Van Genck