Macros for multiline comments in Visual Studio

In my previous post I tried using code snippet to handle multiline comments insertion, but I didn't achieve removing those comments.

What I want to achieve is something like the default behavior for xml files when using the comment and uncomment buttons.

Using macros I can get it! So one macro to put comment (modified from the sample macro in vs) and one to uncomment.

The first surround the start and end selection with comment markers (for c# /* */).

The second takes the caret position and strips the previous start comment marker (/*) and the following end comment marker (*/)

It handles /*  */ and <!-- --> tags. Not VB (yet?)

You can associate this macro with a couple of button (or replace the default ones) and that's it.

Hope this helps someone

Code snippet for multiline comments in Visual Studio

Sometime you want to comment multiple line of c# code.

Visual studio uses // for each line of code if you use the comment/uncomment button.

I wanted to use the multiline comments /* */.

With the following snippet you can do this by using "Surround with"

<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets  xmlns="">
    <CodeSnippet Format="1.0.0">
            <Title>Multiline C# comment</Title>
            <Description>Code snippet for multiline C# comments</Description>
            <Author>Carlo Folini</Author>
                    <ToolTip>Multiline C# comment</ToolTip>
            <Code Language="csharp"><![CDATA[/*$selected$*/]]>

Following this post, I put this snippet under My Documents\Visual Studio 2008\Code Snippets\Visual C#\My Code Snippets.

Didn't find a way to strip the comments tags, anyway

that's it