From the course: Visual Studio Code for Web Developers

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Working with snippets

Working with snippets - Visual Studio Tutorial

From the course: Visual Studio Code for Web Developers

Start my 1-month free trial

Working with snippets

- [Instructor] VS code supports snippets, which you can think of as smart fragments of code that can be inserted by typing just a few characters. This makes it easy to enter common code patterns with less typing. The app ships with several snippets already built in, but you can also define your own. In the editor, let's open the file named script.js, which is in the scripts folder. So let's add a function to this script file by using the snippet. When I type the letters fun you can see that the completion list pops up. There's a couple of entries in here already for the function keyword, and this one down here with the box and the little dots in the bottom is the one I want. That icon indicates that this is a snippet. Snippets have support for tab completion, so if I select that snippet and then hit the Tab key you can see that a skeleton of a function construct has been inserted into the file. There are place holders for the function name, the parameters, and the body of the…

Contents