[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Tabs v.s. spaces



On Tue, Nov 18, 2003 at 11:34:14PM +1100, Hamish Moffatt wrote:
> On Mon, Nov 17, 2003 at 07:57:46PM -0800, Joshua Kwan wrote:
> > Hear, hear. Yes, 8-space indentation is a matter of pressing the Tab
> > key, but it's a bit too big.. I've always stuck with two spaces.
> 
> So set your tabstop (and shiftwidth) in vi to 4, and you'll have four
> character indents. Or 2.

If I can convince myself vi is usable beyond editing simple config files.
;-)

> And if you save the tabs in the files (ie don't use expandtab), then
> whoever else opens your code will get their preference and everybody is
> happy. 

I wouldn't be so quick to say that... for one, I line up my comments with
tabs (8-space tabs), they would be misaligned with a different tab stop,
and would look rather atrocious.

> > Note that if you want to quickly format your code with tab-character
> > indentation (== 8 spaces), I like astyle -t <file>. Works like a charm.
> > I've only tried it with C/C++ code so I don't know whether it works for
> > other kinds of files.
> 
> VIM can do autoindenting for some languages too. Works OK with Perl,
> and C, and badly with Tcl (but doesn't everything?).
[snip]

Generally, I am skeptical of autoindenting tools. I usually do it by hand.
(I don't buy the write-first-indent-later coding philosophy.) Also, my
indenting style is complex enough to elude tools like 'indent'. I firmly
believe in doing something right, right from the start. If something isn't
properly indented when first written, it's broken and must be rewritten.


T

-- 
You've gotten under my skin. That you got there speaks ill of me. That you
like it there speaks ill of you. -- Speek, K5



Reply to: