The basic idea behind Visual Studio 2005 Code snippets is to help developers write more code by actually typing less, while inserting templated code chunks or patterns, which we repeatedly use in our day-to-day coding.
Code snippets are easily accessible from your IDE. You can either type their (abbreviated) name and do some TAB tapping, or right-click in your code window and select:
- Insert Snippet... [for insertion]
- Surround With... [surrounds selected code with the snippet code]
If you prefer using keyboard shortcuts: use Ctrl+K, Ctrl+X for insertion and Ctrl+K, Ctrl+S for surround with.
Writing custom snippets is also easy; you'll find the recipe with all ingredients listed in the MSDN documentation. Try it, it's fun. As an example, I created a simple snippet, which creates the string.IsNullOrEmpty() test block:
You can download this snippet from here. Unzip the .snippet file and copy it to "My Documents\Visual Studio 2005\Code Snippets\Visual C#\My Code Snippets" folder. Enjoy.
[Also, feel free to peek around for other code snippets]
[Update: create code snippets faster with the Code Snippets Editor or Snippy /thanks, D.]
625128af-983f-4b04-a5b6-4f9014ae2c6f|2|1.0|27604f05-86ad-47ef-9e05-950bb762570c
Tags :