Creating Code Snippets in Visual Studio Code

preview_player
Показать описание
If you're interested in learning more about VS Code, check out the "Learn VS Code" course to learn everything you need to know!

Defining code snippets can save you tons of time. They provide developers a way to generate a section of code by using a short code or keyword. In this video, we will cover how to create code snippets in Visual Studio Code.

Resources

-~-~~-~~~-~~-~-
Please watch: "5 Ways To Improve Your Speed With Visual Studio Code"
-~-~~-~~~-~~-~-
Рекомендации по теме
Комментарии
Автор

i was looking for add another snippet for my css and i found it here, thanks a lot.

mizaelmartinez
Автор

wow thanks alot because of you I could create snippets of c language of my own! really thank you!

dakbal-jum
Автор

that looks awesome, I think I'm finally going to make the jump to vs code because of this. thanks

zwiebec
Автор

Very helpful video! Saved tons of time and it's fun these stuff

xNReaperx
Автор

For anyone having issues getting it working: make sure that you choose the right language in the bottom-right corner of your editor and then reload VS Code

quarantinecrosscountry
Автор

your video is excellent. Your video is very much useful to me, Many thanks for that. My warm regards to you.

s.baskaravishnu
Автор

Great! I even backup the setting jason file with an other options to the github cloud by the VScode extension, that works on the github's API gists (without Git installed).

aleksekokorev
Автор

I wish we use snippets of regexps in the command palette.

red
Автор

how can I add an easy html-code to snippets? Everytime ther is a "xyz" it crashes the snippet.


Like in <meta property="og:type" content="blog"/> I need the "og:type" to be inserted with the snippet. Instead, it always creates new lines and kills what is between the " " ... please send help... ;__;


I just want to insert all the needed meta-descriptions with one snippet instead of typing them all again.

FarbcafeDe
Автор

It doesn't work in:
Version 1.24.0-insider
Commit
Datum 2018-05-04T08:10:40.288Z
Shell 1.7.12
Renderer 58.0.3029.110
Node 7.9.0
Architektur x64:

When I type "clog" the suggestion is "ChannelMergerNode".

But it works in Visual Studio Code Version 1.22.2.

Thank you for the video.

RealEstateD
Автор

how to publish it? I want to make some useful snippets and publish it so my friends can use it too?

KenKoyVlogs
Автор

What do you do with the javascript.json file? Where do you store it?

DeniTosh
Автор

What happens when you have a file that has php, html and some mix of other items.

aot
Автор

Very nice!
With keyboard command you can use ${TM_SELECTED_TEXT} to wrap the selected text with a snippet, very useful.
I was wondering if I could restrict a "keybinding" only to one language, like php.
I tried using "langId" like you did:

"args": {
"langId": "php",

but it didn't work, the php snippet executes in other files like javascript.. Any clues how to make it execute only in php files?

Still, I'm happy to be able to do this kind of things, so nice.

nemnoton