KnowDotNet NetRefactor

NET Refactor - Insert Snippet

Automatically Insert User-Definged Code Snippet

Automatically Insert User-Defined Code Snippet with NET Refactor.  Many times, pasting an extended code snippet is faster than typing it.  NET Refactor, Insert Snippets, comes with numerous pre-defined snippets, you can enter as many of your own snippets as you wish.  

If you have a snippet of code that you use over and over, such as the definition of a SqlConnection, or SqlCommand setup, you can select the code snippet in your code window, click on Organizer, Setup Snippets, and a Snippet Setup Dialog will be displayed, and your selected code will have been picked up and the dialog is in Add mode.  At that point, simply enter a name for your snippet and click the Update button on the dialog.  Your snippet is now part of the library, that is maintained in an XML file in the install directory of NET Refactor.

To insert a snippet, place the cursor in the left margin of the code window, where you want the snippet inserted.  Click the Insert Snippet option on the Organizer menu.  The Insert Snippet dialog will be displayed as shown in Figure 1.  

Single-clicking on an item will cause the code to be displayed in a tool tip.  Double-clicking will paste the selection at the cursor point iin the code window.

Figure 1 - Insert Snippet Dialog.

Insert Snippet Dialog


Once you have inserted a snippet, the code will appear as shown below.

      Dim cmd As SqlClient.SqlCommand
      cmd.CommandText =
"Your SQL"
      cmd.Connection = ConnObject
      
Dim da As New SqlClient.SqlDataAdapter(cmd)
      
Dim dt As New DataTable()
      da.Fill(dt)

Try NET Refactor Free for 15 days or purchase now by clicking Download or Purchase.

Top of Page

Writing Add-Ins for Visual Studio .NET
Writing Add-ins for Visual Studio .NET
by Les Smith
Apress Publishing