What are Code Snippets ?

These are saved as XML files and become available in the IDE when you right click in the Code Editor and select Insert Snippet.
Both Visual Basic and VSTO ship with a number of built-in code snippets.



SS = xml file example



Built-in Code Snippets

Visual Studio comes with a number of pre-installed code snippets

Shortcut CodeDescription
TryCTry Catch EndTry
TryCFTry Catch Finally EndTry
TryFTry Finally EndTry



Inserting Code Snippets

There are a number of ways you can insert a code snippet into the editor.
1) Right click the Code Editor and select Insert Snippet
2) Type the shortcut name and press Tab
3) Start typing the first few letters of the shortcut name followed by a question mark and then press Tab to display a drop-down list of available code snippets




Creating your own Code Snippets

You can create your own by creating an XML file and saving it with the .snippet file extension.




Visual Basic Snippet Editor


Code Snippet Editor


Can be downloaded from CodePlex
'http://snippeteditor.codeplex.com


Add arguments and parameters


saved in C:\Program Files\Microsoft Visual Studio 9.0\VB\Snippets\1033\ .snippet


Intellisense code snippets ??



Code Snippets Manager

(Tools > Code Snippets Manager)
click Import
This can be used to add your code snippets to the code snippets folder list.
SS
choose the language at the top




© 2017 Better Solutions Limited. All Rights Reserved. © 2017 Better Solutions Limited

PrevNext