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
-
This is essentially a duplicate of stackoverflow.com/questions/40110541/… . Just make your own snippet and set "editor.snippetSuggestions": "top" You do not want to be editing the built-in snippets.Mark– Mark2018-06-12 04:20:31 +00:00Commented Jun 12, 2018 at 4:20
Add a comment
|
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.
- Go to
File -> Preferences -> User Snippetsand select JavaScript in order to edit snippets for that language. - Add this entry to the opened file
javascript.jsonand 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
3 Comments
chestozo
Also note that both standard and your custom snippets will be show in suggest. And if you want your snippet to go above the standard - you can change
description so that it terms of sort order your description comes before standard snippet description.JesseBoyd
doesn't really solve the problem and adds clutter to the auto complete. see answer below for final solution by Filip Van Gench
zjffun
Using the Snippets Manager extension can quickly edit User snippets.
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
3 Comments
JesseBoyd
works and finally rid of that ugly semi colon! remember to restart vs code to see the changes
qadzek
On Linux, this can be found in
/usr/share/code/resources/app/extensions/javascript/snippets/javascript.code-snippetspeterflynn
Do these edits get lost every time you update VS Code, though?