Change ctrl k+c to produce c style comment (/**/)

2020-04-18 04:18发布

How do i change the comment style used in visual studio from // to /*...*/ ?

I use the comment shortcut mostly for commenting out code temporarily.

It annoys me that if i select bool abc in the code below and press ctrl k+c

void func( bool abc ) {}

it produces

//void func( bool abc ) {}

instead of

void func( /*bool abc*/ ) {}

Regards

Henrik

2条回答
ゆ 、 Hurt°
2楼-- · 2020-04-18 04:50

You can do it with a macro. Make it look like this:

Public Sub CommentSelection()
    If Not DTE.ActiveDocument.Selection.IsEmpty Then
        DTE.ActiveDocument.Selection.Text = "/* " + DTE.ActiveDocument.Selection.Text + " */"
    End If
End Sub

Bind it to a key other than Ctrl-K+C, you'll want to keep that one around.

查看更多
地球回转人心会变
3楼-- · 2020-04-18 05:01

ReSharper does this CTRL + SHIFT + C

Otherwise, a macro would be your best bet, add this to your VS Macros and bind it to a keyboard shortcut of your choosing:

edit: removed my crappy code, nobugz beat me.

查看更多
登录 后发表回答