Save some time with code snippets

preview_player
Показать описание
Рекомендации по теме
Комментарии
Автор

snippet extensions are nice as well.

i like to disable them globally then enable them per workspace. vscode went from 10 GB -> 3 GB of memory

kadensharpin
Автор

Thank you. Vscode is very helpful in so much ways

khaled.hashed
Автор

Here's a literal pro tip:
Use "Easy Snippet"

I know VSCode let's you add usersnippets — but you don't create them cause it bothers your workflow. Easy Snippet; you select existing code

→ Create Snippet from selection (automatically detects langauge)
→ Looks like a regular code block (no JSON involved)
→ Add VSCode snippet syntax e.g. `public class ${1:ClassName} { ${0:}` etc.

Thank me later.

--Arthur
Автор

Lol, I did this so I wouldn’t have to write console.log, I set it so I just type clog and it adds it and puts the cursor in the (), and if I want to write a message and not pass in a variable I set clogm to generate console.log(“”) and put the cursor between the quotes.

One of my best choices every.

Beastintheomlet
Автор

I also noticed if you highlight something then just start typing and then select the snippet it will be put in the code that you just overwrote but inside the snippet

otter
Автор

I wish there was a better way to add and edit snippets in vscode this is barely useable even for short snippets let alone longer boilerplate code. I miss live templates from phpstorm it has a full editor you can edit the body with smart features really useful. Love vscode though this is one of few features I really miss from jetbrains.

jollen
Автор

Where was this last week when I needed it? lol

phil-o-phobic
Автор

Eventually VSC will support custom code snippets as macros with an associated build step, and we’ll have gone full circle on meta programming

DeusGladiorum
Автор

I usually just use global snippets and just specify the scope

pipzgutz
Автор

That's nice and all, but you can't include a snippet into your snippet, yet. That would be really helpful.

Tekay
Автор

Could you help me, write an example of grammar ${' int ':?' if ':' else '}  usage  , i 'm a little bit stupid, read serveal times of offical document, but still don't know how to use if-else in condition snippets, this is what i writed, ${1:'hello world'}, i wanna if the filename endwith .py print hello python, elseif endwith .vue print hello vue, but i can't figure it out, please help me, thanks a lot

yingpwu