VCS JS snippets
Hey all.
I have two questions regarding VCS JS snippets and maybe regarding JS itself.
1. From what I see in the documentation (and I might be wrong, I am new to this), console.log() should always have an object passed to it. I tried running console.log and nothing happens, no error, but it is pointless, am I wrong? So, why isn't VSC just writing the whole thing? Eg. of what I wish for: I start typing "cons" it offers the word "console", I press enter, I write a dot "." and then I write "lo" and it offers "log()" and puts the pointer between the brackets. Similar with Math.random(), for example.
Note: This is not a complaint about VSC, I can write the snippet myself. I am just trying to understand how it works and why.
2. No addons. When I start writing "for" in my JS file, what is this first option that is shown? Can I remove it? I see it for other commands as well.
Thanks a lot.
9 Replies
that is from Emmet specificily not snippets
like you said you can make your own snippets though.
I do
cd
for console.dir() for example.
Also most my JS snippets start withj
since its one the most unused letters, if that helps any.
so like jfo
for for loopsHow did you know that this was from Emmet? So I can found out this type of information by myself in the future.
It certainly does, thanks.
the icon next to it. Snippets have the []
and I might be wrong emmet has 🔧
more on it and its settings https://code.visualstudio.com/docs/editor/emmet here though.
not sure what the lines one is ...
You can change in the settings for snippets to show up first too though
like for me its
also
"editor.suggest.snippetsPreventQuickSuggestions": false,
is a great feature if you want autocomplete to still work in snippets
oh there is a setting to have emmet show up as snippets too interesting xDIIRC the lines is to signify it's a token of the language, you should have the same proposed for
break
for example (choose that one because there's no point in doing a snippets for it but it must still come up in the autocomplete window
As for the console.log
question. log
expects from 0 to n parameters (has to be a limit but I don't know it) so by default the inteliscence will autocomplete it with the 0 parameter signature. IIRC the position of the caret after the autocomplete event depends on your settings, you can have it be inside the parenthesis or not.List of the icons in the inteliscence window and their meaning : https://code.visualstudio.com/docs/editor/intellisense#_types-of-completions
IntelliSense in Visual Studio Code
Learn about Visual Studio Code IntelliSense (intelligent code completion).
Perfect, thanks both.
Moved them to top so I don't have to deal with the random stuff.