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

Re: Changing C comments

Expand Messages
  • Bob von Knobloch
    On 28/09/12 22:36, Ben Fritz wrote: ... You are right Ben, For braces, I wanted to change e.g. : func() { body; } to: func() { body; } Marc Jessome
    Message 1 of 7 , Sep 29, 2012
    • 0 Attachment
      On 28/09/12 22:36, Ben Fritz wrote:
      > Oops. Here's a tweak to not include the trailing whitespace within the comment:
      > %s#\v/\*(%(%(\*/)@!.){-})\s*\*/\s*$#//\1
      > (untested)
      > As you can see, you can easily spend WAY to long tweaking these.
      > Here I'm using a "non-greedy" regular expression, see :help /\{-
      >> Now I need to align them. The NERD Commenter didn't work well for me.
      >> Pity, it looked as though it could solve my aligning problem.
      >> Now I need a K&R style to "braces horizontally aligned" brace conversion :=)
      > I'd understand your alignment problem better if you gave an example. But probably it's not something you should use regex to accomplish. There is an "Align" plugin by Dr. Chip but since I don't really understand your problem I'm not sure if it's useful:
      > http://vim.sourceforge.net/scripts/script.php?script_id=294
      You are right Ben,
      For braces, I wanted to change e.g. :

      func() {
      body; }



      Marc Jessome suggested "http://astyle.sourceforge.net/" for this job and
      it works like a charm for all possible brace combinations. It's not a
      tool I knew of.

      Thanks Marc.

      Now for comments, I want to change:

      // Comment1
      // Comment2


      // Comment1
      // Comment2
      where I can specify ---------^ this column.
      (Long source code lines wuill 'push' this to the right)

      (Format might get mangled by mail/list) :=)

      On 29/09/12 02:27, jreidthompson wrote:
      > are you certain this code will never need to be compiled on an
      "older" compiler? ISO C90 or earlier, any C compiler that will not
      allow C++ style comments, etc???

      Yes thanks, that is exactly why I want to convert the files.
      I find the older styles harder to ascertain the logical flow in. (Just
      my preference).

      Many thanks to all,


      The Sun is out, the sky is blue, it's time to drive the MR2.

      You received this message from the "vim_use" maillist.
      Do not top-post! Type your reply below the text you are replying to.
      For more information, visit http://www.vim.org/maillist.php
    Your message has been successfully submitted and would be delivered to recipients shortly.