Visual Studio 2008 indented C comment / * * /

I am new to using the Visual Studio 2008 IDE. Transition from vim. Is there a way to configure Visual Studio to automatically indent C comments / * * / such as:

/*<ENTER>

I want it:

/*
 * <CURSOR>

Edit: It appears that Visual Studio 2008 has this behavior for C # comments, but not for C / C ++: Text Editor> C #> Advanced> Creating XML Documentation Comments for ///

+3
source share
5 answers

You can use the following macro in your EnvironmentEventsproject element . It should work for all tab styles (None, Block or Smart).

    Public Sub aftekeypress(ByVal key As String, ByVal sel As TextSelection, ByVal completion As Boolean) _
            Handles TextDocumentKeyPressEvents.AfterKeyPress

        If (Not completion And key = vbCr) Then
            Dim textDocument As TextDocument = DTE.ActiveDocument.Object("TextDocument")
            Dim startPoint As EditPoint = TextDocument.StartPoint.CreateEditPoint()
            startPoint.MoveToLineAndOffset(sel.ActivePoint.Line - 1, 1)
            Dim lines = startPoint.GetLines(sel.ActivePoint.Line - 1, sel.ActivePoint.Line)
            If lines.LastIndexOf("*") = 1 And lines.LastIndexOf("/") <= 0 Then
                If lines.LastIndexOf("/") = 0 Or _
                   DTE.Properties("TextEditor", "C/C++").Item("IndentStyle").Value = 0 Then
                    sel.Insert(" ")
                End If
                sel.Insert("* ")
            End If
        End If
    End Sub
+2
source

It seems to me that he is already doing this.

+1

, , , , Visual Studio 2010 ReSharper . , , . , Visual Studio 2010, , , .

  • Visual Studio
  • Alt + F8, Macro Explorer
  • samples
  • "VSEditor"

  • NewCommentLine
  • GetCommentLinePrefix
+1

, Add Reflower addin:

http://www.kynosarges.de/CommentReflower.html ( VS2008 +) http://commentreflower.sourceforge.net/ ( VS2005)

emacs; , ( , ), , . - , vim , , ? - , .

Windows, , , C , - , :

/* This is what Comment Reflower will do with your multi-line
 * C comments, as far as I can remember.
 */

, . ( .)

, - Xcode. ( iPhone, , œ , , .) vim , , , emacs. ( , vim, , , - , , VIM. )

( - , Visual Studio 2005, , . , 2008 ? , OK, , - , , , ++ //. Comment Reflower .)

+1

Visual Assist X . ReShaper C/++ , ReSharper C/++. "/**", .

PS: in this fragment configuration, you can even automatically generate documentation as you wish. Sort of:

+1
source

Source: https://habr.com/ru/post/1731117/


All Articles