Using Snippets
Leave a commentOctober 17, 2016 by Kenneth Fisher
A while ago I talked about Templates. This is an easy way to get a, well, template of a piece of code. But a much faster way to get a simple template is to use a snippet. With a simple key command (ctrl-K, ctrl-X) you can open up the snippet picker and quickly navigate to the snippet you need.
Note: You can also open the snippet picker by right clicking and selecting Insert Snippet… or from the menu Edit -> Intellisense -> Insert Snippet…
Further note: snippet picker sounds really odd but it was the name in BOL so we’ll go with it.
Demo time! First things first I want to add a new snippet. I opened the Snippet Manager.
and selected a snippet I wanted to model on. When you look at the snippet through the manager you can see the file location. I opened it up in notepad (it’s just a simple XML file), modified it, then saved it alongside the original.
I should point out that the file was located in a protected location so I had to open notepad as an administrator. Once I saved the file my new snippet was ready to go.
Well, actually I had to create another new snippet before it would show up in the snippet picker (or possibly I could have re-started SSMS).
Now I was ready to start creating code!