Guido i/view
plug-discuss@lists.PLUG.phoenix.az.us
plug-discuss@lists.PLUG.phoenix.az.us
Sat, 21 Apr 2001 11:16:01 -0700
So, what was your preferred indentation style back then?
Do you still prefer your old style but you're being
"encouraged" to use a style you don't like, or have
you switched styles? And of course, "why?" :)
> A related matter is defining (or agreeing upon) how many spaces a tab
> expands to. Of course, the right answer is eight ;-), but, depending
Actually, the right answer is "it doesn't matter."
The big "BUT" is that you should ONLY use TABs for
LOGICAL indentation. In other words, when you're
at the beginning of a line and hitting the <TAB>
key, the first time that you press ANY key other
than the <TAB> key (OK, maybe the <SHIFT> key is
an exception :) ), you may NEVER use the <TAB>
key again on the current line, you MUST use the
spacebar.
For example:
wrong:
<TAB><TAB>printf("stuff\n");<TAB><TAB><TAB>/* this prints stuff */
right:
<TAB><TAB>printf("stuff\n"); /* this prints stuff */
Try entering lines like these in your favorite
editor (well, at least an editor that supports
TABs), then try changing the tab spacing. If
you only use TABs at the beginning of the line,
the tab spacing doesn't matter. The first line
requires you to use the same tab spacing as the
original author so things don't look messed up.
Mi Dos Pesos,
D
* On Fri, Apr 20, 2001 at 09:44:08PM -0700, Kevin Buettner wrote:
> On Apr 20, 7:18pm, der.hans wrote:
>
> > Anybody know of a Free Software code beautifier? Something that lets me
> > see code how I like it however it looks on disk and lets others bring it
> > up in whatever heathen format they like?
>
> For C (and maybe C++) code, there's GNU indent. See
>
> http://www.gnu.org/software/indent/indent.html
>
> I once worked for a small company where we had indentation wars. I
> had written the bulk of the code in the project and some of my
> colleagues would (in the process of working on it) reindent the code
> with Emacs' defaults. When I got ahold of the code again, I'd reindent
> it back the way that I liked it. We went back and forth like this for
> a while; it was very painful doing merges between our code bases. I
> finally learned about GNU indent and hacked it so that, once run, it
> was a mostly idempotent operation. (I.e, once you'd indented to a
> certain style, if you ran it again on the same code, nothing would be
> changed.) It's a shame that I never did get around to contributing
> those changes.
>
> I've learned to be more tolerant of different styles in the years
> since. In fact, these days, working on GDB, I'm using the very
> indentation style that I found so repulsive those many years ago. My
> advice these days is to be flexible and adapt to whatever style a
> particular project has adopted. I also think it's important for a
> project to standardize on a particular style and stick to it. It's
> very annoying to have to switch indentation schemes between different
> files in the same project (or even different functions in the same
> file).
>
> A related matter is defining (or agreeing upon) how many spaces a tab
> expands to. Of course, the right answer is eight ;-), but, depending
> on where I've worked, I've adapted to setting it to be four and other
> strange values too.
>
> Kevin