the chris o show

Snippet in Visual Studio to create static method

June 27th 2007

After using Textmate for a couple of weeks I’ve come to realise how incredibly powerful and beautiful it is! Creating text snippets is a breeze – and improves productivity no end!

To achieve the same affect in Visual Studio though is a right pain in the butt-ocks. All I wanted to do was create a very basic snippet to define a static method (because I was creating a bunch of them all at the same time) and had to get down and dirty with some XML.

Anyhoo – here’s my result:

<?xml version="1.0" encoding="utf-8"?>
  <codesnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  <codesnippet format="1.0.0">
  <header>
    </header></codesnippet></codesnippets>
Public Static Method Declaration pubs Code snippet for creating a static method Chris O'Sullivan Expansion return_type Return Type void method_name Method Name method param_type Param Type param_type param Name of Param param

Then you just type pubs[tab] and it will create a declation like this:

public static void method(param_type param)
{
}

With the ability to tab between the different fields.

But oh man what a pain that was to do! (I love you textmate – xx)

blog comments powered by Disqus