Re: restyling C/C++ ?
- 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??)I think that "gg=G" has already been explained well. I can confirm
> 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 ;) )
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
and follow the link to the explanation of 'equalprog'. Second, see
whether astyle or GNU indent, or some other program, does what you want.
> Also, a more practical problem, I found in the vim faq,[snip]
> (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.
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
Or maybe you should start earlier in the docs, with
I strongly suggest using an ftplugin/ directory instead of a syntax/
directory, as another post suggested.
HTH --Benji Fisher