Re: A stylistic question.



"James Dow Allen" <jdallen2000@xxxxxxxxx> writes:
[...]
My "normal indent" is one TAB character, and I'm amazed people
mess around with spaces. It seems futile to try a TAB other than
8 spaces, though I admit 6 spaces would be slightly better.
4 spaces of indentation is almost too little for my taste.
I *do* like being able to line up begins and ends easily, so if I was
ever forced to work on code that used (gasp!) 2-space indentation
I'd become an indent(1) fan *real* quick. (2-space indentation may
look
OK on little fragments, but am I the only one that ever puts more than
3 or 4 lines of code into the body of a for or if?)

It's important to distinguish between tabstops and indentation levels.
Too many people seem to think they have to be the same thing.

Tabstops, in my opinion, should be set at 8 columns, always. That's
the default setting on every system I've used. Setting it to
something other than 8 means that anything containing tabs will look
different in *some* context (printing, viewing with a different
editor, etc.).

My own preferred indentation level has changed over the years;
currently, I like 4 spaces. My preferred text editor, vi, has
separate settings for "tabstop" and "shiftwidth". I type ^T at the
beginning of a line to indent by one shiftwidth, and ^D to un-indent
by one shiftwidth. vi automatically converts indentation to a
sequence of tabs and spaces (for example, a 12-column indent becomes a
tab followed by four spaces); it's a feature I wish I could turn off,
but I live with it. (I think some versions of vi can turn this off;
nvi can't.) I've defined an editor macro that filters the buffer
through "expand", which expands all tabs to the right number of
spaces.

I have no doubt that emacs can do something similar.

For the most part, I don't "mess around with spaces"; I let my editor
take care of it for me. Computers are generally pretty good at that
kind of thing.

--
Keith Thompson (The_Other_Keith) kst-u@xxxxxxx <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
.



Relevant Pages

  • Re: AfxGetApp() returns NULL
    ... VS to edit my code, it gets the identation right, following my indentation ... OPTION of whether to use spaces or tabs. ... me, and written using my editor, and given away free to others as a courtesy, I see no ... of my automation; worse still, the creators of VS think that there is no ...
    (microsoft.public.vc.mfc)
  • Re: Request for comment on my tiny learning project: dfighterdb (mytree)
    ... -In most of your code I looked at, your closing braces line up with ... -Your code uses tabs for indentation. ... The cast is unnecessary. ... I don't do the indentation myself. ...
    (comp.lang.c)
  • Re: Tabs vs. Spaces
    ... > everyone who reads my code has to suffer from my indentation style. ... code and view it on a viewer with 2-space tabs). ... programmers in general hate tabs. ...
    (alt.comp.lang.learn.c-cpp)
  • Re: Coding Style: indenting with tabs vs. spaces
    ... While I respect you opinion about tabs, I find tab indentation the most ... Tabs become "logical indentation". ... isn't forced on anotherone's editor. ... any patches to the Linux kernel will have tabs used correctly. ...
    (Linux-Kernel)
  • Re: Using TABs vs. spaces II. (the Philosophy flamewar reloaded ;-))
    ... I read somewhere that good-style Ruby code is indented by 2 spaces. ... code if the indentation is only at 2 spaces. ... spaces or just tabs rather than switching between the two. ... You can alter tab length in your editor (for at least most editors, ...
    (comp.lang.ruby)