Issue #121 (Surround with Snippet)08/14/24
|
Bring together your GitHub, Stack Overflow, and LinkedIn profiles into a single HackerPulse dev profile. Perfect for job applications and networking, HackerPulse gives a complete picture of your skills and projects, all in one place.
Sign Up โ
|
|
More than likely you've heard of the Code Snippets feature in VS Code, which allows you to automatically insert a prewritten piece of code. You can choose from an existing library of built-in snippets for JavaScript, TypeScript, Markdown, PHP, and others. Or you can write and save your own snippets. For a more comprehensive look at the topic, check out
this docs article or the brief intro I published in this newsletter in
this issue.
One feature I didn't mention back then is something called
"Surround with Snippet". This is a useful way to incorporate a snippet directly with a line of code in your editor.
To use it, simply select a piece of code, then open your command palette and search for the "Surround with Snippet" command.
Once you select that, you'll then get the usual list of options that shows the snippets you have the ability to insert.
The following animated GIF demonstrates how quickly you can use this feature to insert a snippet that surrounds a selected piece of code:
This is useful for code blocks that use if statements, try/catch, promises, loops, and more. The feature was added a little over two years ago, in February 2022, so I imagine many of you may not have known about it until now.
Now on to this week's hand-picked links!