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

Re: restyling C/C++ ?

Expand Messages
  • Antoine J. Mechelynck
    ... [...] RTFM gg Go to begin of file = {motion} Filter {motion} through the extarnal equalprg or, if undefined (default) through internal C-indenting
    Message 1 of 12 , Jun 2, 2004
    • 0 Attachment
      Joris Huizer <jorishuizer@...> wrote:
      > > Allright the gg=G does do the indenting :-) (what's the gg part
      > > there??)
      [...]

      RTFM

      gg Go to begin of file

      = {motion} Filter {motion} through the extarnal 'equalprg' or, if
      undefined (default) through internal C-indenting

      G Go to end of file.

      Regards,
      Tony.
    • Erlend Hamberg
      ... I don t think Vim can do that, but astyle can. http://astyle.sourceforge.net/ -- Erlend Hamberg ehamberg@online.no All your Languages are belong to us! You
      Message 2 of 12 , Jun 2, 2004
      • 0 Attachment
        On Wednesday 02 June 2004 23:28, Joris Huizer wrote:
        > As I type new code, all is done fine by some vim settings I got
        > somewhere, but I've got no idea of how to make vim restyle "existing"
        > code. Is this possible?

        I don't think Vim can do that, but astyle can.
        http://astyle.sourceforge.net/

        --
        Erlend Hamberg
        ehamberg@...

        All your Languages are belong to us!
        You have no chance to compile!
        make your_time
      • Brent Rice
        From the usage of astyle (what I understand from having glanced at the documentation), it appears that you could probably just use ... or, for a visual line
        Message 3 of 12 , Jun 2, 2004
        • 0 Attachment
          From the usage of astyle (what I understand from having glanced at the
          documentation), it appears that you could probably just use

          :%!astyle_command_with_the_options_that you want

          or, for a visual line selection,

          :'<,'>!astyle_command_with_the_options_that you want

          from within vim. I obviously have not tested this, but figured that it
          was a simple addition worth noting.

          Brent



          On Jun 2, 2004, at 5:23 PM, Erlend Hamberg wrote:

          > On Wednesday 02 June 2004 23:28, Joris Huizer wrote:
          >> As I type new code, all is done fine by some vim settings I got
          >> somewhere, but I've got no idea of how to make vim restyle "existing"
          >> code. Is this possible?
          >
          > I don't think Vim can do that, but astyle can.
          > http://astyle.sourceforge.net/
          >
          > --
          > Erlend Hamberg
          > ehamberg@...
          >
          > All your Languages are belong to us!
          > You have no chance to compile!
          > make your_time
          >
        • PAN Shizhu
          I recommend you use GNU indent together with the = command. ... then gg=G The GNU indent is a very feature rich and highly customizable utility. IMO it is
          Message 4 of 12 , Jun 3, 2004
          • 0 Attachment
            I recommend you use GNU indent together with the '=' command.

            In VIM you can do:
            :%!indent
            then
            gg=G

            The GNU indent is a very feature rich and highly customizable utility. IMO
            it is far versatile than astyle. If you carefully choose the parameters of
            GNU indent to suit your need, you may omit the step 'gg=G'.

            The GNU indent is avaiable online, and is included in most GNU
            distributions. (Linux, FreeBSD, Cygwin, etc.)

            HTH
            Pan Shizhu.

            _________________________________________________________________
            与联机的朋友进行交流,请使用 MSN Messenger: http://messenger.msn.com/cn
          • Charlie Farbstein
            The last time I checked, GNU indent worked well for C code but did not handle C++ code very well. Charlie Farbstein ... From: PAN Shizhu
            Message 5 of 12 , Jun 3, 2004
            • 0 Attachment
              The last time I checked, GNU indent worked well for C code but did not
              handle C++ code very well.

              Charlie Farbstein

              ----- Original Message -----
              From: "PAN Shizhu" <dicpan@...>
              Date: Thursday, June 3, 2004 0:35 am
              Subject: Re: restyling C/C++ ?

              > I recommend you use GNU indent together with the '=' command.
              >
              > In VIM you can do:
              > :%!indent
              > then
              > gg=G
              >
              > The GNU indent is a very feature rich and highly customizable
              > utility. IMO
              > it is far versatile than astyle. If you carefully choose the
              > parameters of
              > GNU indent to suit your need, you may omit the step 'gg=G'.
              >
              > The GNU indent is avaiable online, and is included in most GNU
              > distributions. (Linux, FreeBSD, Cygwin, etc.)
              >
              > HTH
              > Pan Shizhu.
              >
              > _________________________________________________________________
              > ���������������������������� MSN Messenger:
              > http://messenger.msn.com/cn
              >
              >
            • Neil Bird
              Around about 02/06/2004 23:13, Joris Huizer typed ... ... I guess it s being set by the cpp.vim syntax file; any setting you make will then be reset by that.
              Message 6 of 12 , Jun 7, 2004
              • 0 Attachment
                Around about 02/06/2004 23:13, Joris Huizer typed ...
                > :set comments=sr:/*,mb:*,el:*/
                >
                > Is there a way to get this to work as a default? I tried putting that
                > (without the : thing) in my ~/.vimrc but it wouldn't work -- can you
                > tell me what's wrong? I attached my ~/.vimrc file.

                I guess it's being set by the cpp.vim syntax file; any setting you
                make will then be reset by that. Create a ~/.vim/after/syntax/cpp.vim
                and put it in there (this file is run after the cpp syntax file is run).

                --
                [neil@fnx ~]# rm -f .signature
                [neil@fnx ~]# ls -l .signature
                ls: .signature: No such file or directory
                [neil@fnx ~]# exit
              • Benji Fisher
                ... I think that gg=G has already been explained well. I can confirm what another post suggested tentatively: the internal reformatting done with = only
                Message 7 of 12 , Jun 9, 2004
                • 0 Attachment
                  On Thu, Jun 03, 2004 at 12:13:48AM +0200, Joris Huizer wrote:
                  > Allright the gg=G does do the indenting :-) (what's the gg part there??)
                  > But there is still a small problem - in some ugly code lines aren't
                  > broken of the way they should be, like, after an if() the code just
                  > continues on the same line (well this is "uglyfied" code to be honest,
                  > but it'd be really cool if vim could make it real nice code that'd be
                  > *really* good ;) )

                  I think that "gg=G" has already been explained well. I can confirm
                  what another post suggested tentatively: the internal reformatting done
                  with = only affects indent, i.e., leading white space. It will not
                  break nasty lines.

                  If you combine some suggestions from other posts, you may get
                  something very convenient to use. First, RTFM: start with

                  :help =

                  and follow the link to the explanation of 'equalprog'. Second, see
                  whether astyle or GNU indent, or some other program, does what you want.
                  Finally,

                  :set equalprg=...
                  gg=G

                  > Also, a more practical problem, I found in the vim faq,
                  > (http://vimdoc.sourceforge.net/cgi-bin/vimfaq2html3.pl#27.7) :
                  > :set comments=sr:/*,mb:*,el:*/
                  > will disable the repetition of the // comment in C++
                  >
                  > Is there a way to get this to work as a default? I tried putting that
                  > (without the : thing) in my ~/.vimrc but it wouldn't work -- can you
                  > tell me what's wrong? I attached my ~/.vimrc file.
                  [snip]

                  From the part I snipped, it looks as though you started with the
                  sample vimrc file from the distribution, so things like ftplugins should
                  be enabled. Then you want to put the :set lines (the one I suggested
                  and the one quoted above) in your ftplugin/c.vim file, or maybe
                  after/ftplugin/c.vim . See

                  :help ftplugin-overrule

                  Or maybe you should start earlier in the docs, with

                  :help ftplugins

                  I strongly suggest using an ftplugin/ directory instead of a syntax/
                  directory, as another post suggested.

                  HTH --Benji Fisher
                Your message has been successfully submitted and would be delivered to recipients shortly.