Search code examples
visual-studiovisual-studio-2008code-snippets

Can I define custom "surround with" templates in Visual Studio 2008?


Can I define custom "surround with" templates in Visual Studio 2008?


Solution

  • Here you go, this is an example to set everything selected inside {}

    In tools, codesnipet manager.

    <?xml version="1.0" encoding="utf-8" ?>
    <CodeSnippets  xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
        <CodeSnippet Format="1.0.0">
            <Header>
                <Title>{}</Title>
                <Shortcut>{}</Shortcut>
                <Description>Code snippet for {}</Description>
                <Author>Sérgio</Author>
                <SnippetTypes>
                    <SnippetType>Expansion</SnippetType>
                    <SnippetType>SurroundsWith</SnippetType>
                </SnippetTypes>
            </Header>
            <Snippet>
                <Code Language="csharp"><![CDATA[{ 
            $selected$ $end$ 
        }]]>
                </Code>
            </Snippet>
        </CodeSnippet>
    </CodeSnippets>