Search code examples
visual-studio-2010code-snippets

C# Custom Code Snippet Functions


I have a code snippet structures like so:

    private $type$ $lowercaseName$;
    public $type$ $uppercaseName$
    {
        get { return $lowercaseName$; }
        set { $lowercaseName$ = value; }
    }

It generates stuff like:

    private string randomValue;
    public string RandomValue
    {
        get { return randomValue; }
        set { randomValue = value; }
    }

Thats a very oversimplified version... its really a lot more complicated... and its just that much more information to type in. It would be nice if you could type in $uppercaseName$, and then a custom snippet function would assign a value to $lowercaseName$....

But is it even possible to write custom snippet functions? I don't see anything about this in the documentation...

If it is possible... how?


Solution

  • It is not yet possible. See this suggestion for 2010 that was denied.

    http://connect.microsoft.com/VisualStudio/feedback/details/523601/allow-custom-code-snippet-functions

    It seems this feature was suggested when snippets were introduced, and has been re-suggested every version, and shot down saying they don't have enough time.