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

Re: restyling C/C++ ?

Expand Messages
  • 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 1 of 12 , Jun 9 6:29 PM
      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.