Loading ...
Sorry, an error occurred while loading the content.
 

C Comment Autoindenting

Expand Messages
  • Asddfs Adf
    When autoindenting C comments, I d like the left most character of the end comment to be aligned with the left most character of the begin comment: /* */. With
    Message 1 of 6 , May 1, 2009
      When autoindenting C comments, I'd like the left most character of the end comment to be aligned with the left most character of the begin comment:
      /*
      */.

      With everything that I try, I can only get the *'s to align automatically.
      /*
       */.

      Is there a way to get the / to align with the *?

      Thanks

      Jay


      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---

    • Nicolas Sebrecht
      ... Sorry for that question, but why? It s much more readable like this: /* * Comment */ No? -- Nicolas Sebrecht
      Message 2 of 6 , May 1, 2009
        On Fri, May 01, 2009 at 11:33:11AM -0700, Asddfs Adf wrote:
        > When autoindenting C comments, I'd like the left most character of the
        > end comment to be aligned with the left most character of the begin
        > comment:
        > /*
        > */.
        > With everything that I try, I can only get the *'s to align
        > automatically.
        > /*
        > */.
        > Is there a way to get the / to align with the *?

        Sorry for that question, but why?

        It's much more readable like this:
        /*
        * Comment
        */

        No?

        --
        Nicolas Sebrecht

        --~--~---------~--~----~------------~-------~--~----~
        You received this message from the "vim_use" maillist.
        For more information, visit http://www.vim.org/maillist.php
        -~----------~----~----~----~------~----~------~--~---
      • Matt Wozniski
        ... Not if the rest of the codebase is already using /* Comment 1 2 3 */ nor if the above is your company s style guideline. OP: This is explained in the help
        Message 3 of 6 , May 2, 2009
          On Sat, May 2, 2009 at 2:55 AM, Nicolas Sebrecht wrote:
          >
          > On Fri, May 01, 2009 at 11:33:11AM -0700, Asddfs Adf wrote:
          >>    When autoindenting C comments, I'd like the left most character of the
          >>    end comment to be aligned with the left most character of the begin
          >>    comment:
          >>    /*
          >>    */.
          >>    With everything that I try, I can only get the *'s to align
          >>    automatically.
          >>    /*
          >>     */.
          >>    Is there a way to get the / to align with the *?
          >
          > Sorry for that question, but why?
          >
          > It's much more readable like this:
          >    /*
          >     * Comment
          >     */
          >
          > No?

          Not if the rest of the codebase is already using

          /*
          Comment
          1
          2
          3
          */

          nor if the above is your company's style guideline.

          OP: This is explained in the help at :help format-comments, you can
          probably figure it out from that (or at least ask a more specific
          question) in less time than it would take someone else to decide to
          brush up on that section himself and then hand you the answer.
          Basically, you'll have to figure out the format of the 'comments'
          option and set it to what you want.

          ~Matt

          --~--~---------~--~----~------------~-------~--~----~
          You received this message from the "vim_use" maillist.
          For more information, visit http://www.vim.org/maillist.php
          -~----------~----~----~----~------~----~------~--~---
        • Asddfs Adf
          I read the recommended section before posting. I am able to get /* Comment 1 2 3 */ The problem is I can t get the closing * to align with the opening /
          Message 4 of 6 , May 3, 2009
            I read the recommended section before posting.  I am able to get

            /*
               Comment
               1
               2
               3
             */

            The problem is I can't get the closing '*' to align with the opening '/' (it always align's the '*''s).  The format-comments section talks about aligning the middle section with the beginning or end section, but not aligning the end section with the beginning.  Is it possible to align the opening '/' with the closing '*', or am I going to be stuck with deleting the space infront of */ to meet our coding standard?

            Thanks

            Jay


            From: Matt Wozniski <mjw@...>
            To: vim_use@...
            Sent: Saturday, May 2, 2009 2:16:49 AM
            Subject: Re: C Comment Autoindenting


            On Sat, May 2, 2009 at 2:55 AM, Nicolas Sebrecht wrote:
            >
            > On Fri, May 01, 2009 at 11:33:11AM -0700, Asddfs Adf wrote:
            >>    When autoindenting C comments, I'd like the left most character of the
            >>    end comment to be aligned with the left most character of the begin
            >>    comment:
            >>    /*
            >>    */.
            >>    With everything that I try, I can only get the *'s to align
            >>    automatically.
            >>    /*
            >>     */.
            >>    Is there a way to get the / to align with the *?
            >
            > Sorry for that question, but why?
            >
            > It's much more readable like this:
            >    /*
            >     * Comment
            >     */
            >
            > No?

            Not if the rest of the codebase is already using

            /*
            Comment
            1
            2
            3
            */

            nor if the above is your company's style guideline.

            OP: This is explained in the help at :help format-comments, you can
            probably figure it out from that (or at least ask a more specific
            question) in less time than it would take someone else to decide to
            brush up on that section himself and then hand you the answer.
            Basically, you'll have to figure out the format of the 'comments'
            option and set it to what you want.

            ~Matt


            --~--~---------~--~----~------------~-------~--~----~
            You received this message from the "vim_use" maillist.
            For more information, visit http://www.vim.org/maillist.php
            -~----------~----~----~----~------~----~------~--~---

          • Matt Wozniski
            ... Seems to do the trick for me. ... Please bottom post on this mailing list in the future; it s the established mailing list convention, which is why all the
            Message 5 of 6 , May 3, 2009
              On Mon, May 4, 2009 at 12:36 AM, Asddfs Adf wrote:
              > I read the recommended section before posting.  I am able to get
              >
              > /*
              >    Comment
              >    1
              >    2
              >    3
              >  */
              >
              > The problem is I can't get the closing '*' to align with the opening '/' (it
              > always align's the '*''s).  The format-comments section talks about aligning
              > the middle section with the beginning or end section, but not aligning the
              > end section with the beginning.  Is it possible to align the opening '/'
              > with the closing '*', or am I going to be stuck with deleting the space
              > infront of */ to meet our coding standard?

              :set comments=s:/*,m:\ \ ,e-3:*/ cinkeys+=/

              Seems to do the trick for me.

              > ________________________________
              > From: Matt Wozniski <xxx@...>
              > To: xxx@...
              > Sent: Saturday, May 2, 2009 2:16:49 AM
              > Subject: Re: C Comment Autoindenting
              >
              >
              > On Sat, May 2, 2009 at 2:55 AM, Nicolas Sebrecht wrote:

              Please bottom post on this mailing list in the future; it's the
              established mailing list convention, which is why all the responses to
              your original question have been bottom posted.

              ~Matt

              --~--~---------~--~----~------------~-------~--~----~
              You received this message from the "vim_use" maillist.
              For more information, visit http://www.vim.org/maillist.php
              -~----------~----~----~----~------~----~------~--~---
            • Reid Thompson
              ... was wondering if anyone could help me with automating this... My companies standard commenting format. comment left aligned, not indented begin and end
              Message 6 of 6 , May 28, 2009
                On Fri, 2009-05-01 at 11:33 -0700, Asddfs Adf wrote:
                > When autoindenting C comments, I'd like the left most character of the
                > end comment to be aligned with the left most character of the begin
                > comment:
                > /*
                > */.


                was wondering if anyone could help me with automating this...

                My companies standard commenting format.
                comment left aligned, not indented
                begin and end comment lines asterisk padded out to column 79

                is there any way to dynamically calculate and populate the begin and end
                comment lines? either via the comments format parameter or a function?

                /******************************************************************************
                *
                * Function : main
                * Description : Program entry point and top-level program breakdown.
                *
                ******************************************************************************/
                int
                main(int argc, char **argv)
                {
                int exitec = 0;

                /**************************************************************************
                * enable/disable signals
                **************************************************************************/

                if ( ! exitec )
                {
                if (signal(SIGINT, (void(*)(int))mySIGINTHandler) == SIG_ERR)
                {
                /*****************************************************************
                * just a dummy comment to illustrate standard
                *****************************************************************/

                fprintf(stderr, "ERROR: %s: %s", argv[0], PROGERR001);
                fprintf(stderr, "\n");
                exitec = 1;
                }
                }
                ....

                thanks,
                reid



                --~--~---------~--~----~------------~-------~--~----~
                You received this message from the "vim_use" maillist.
                For more information, visit http://www.vim.org/maillist.php
                -~----------~----~----~----~------~----~------~--~---
              Your message has been successfully submitted and would be delivered to recipients shortly.