Re: Tabs, spaces, indent and 80 character lines



On Feb. 25, 2008, 13:40 -0800, Richard Knutsson <ricknu-0@xxxxxxxxxxxxxx> wrote:
Benny Halevy wrote:
On Feb. 24, 2008, 7:40 -0800, Richard Knutsson <ricknu-0@xxxxxxxxxxxxxx> wrote:

Krzysztof Halasa wrote:

Richard Knutsson <ricknu-0@xxxxxxxxxxxxxx> writes:



Why hinder a developer who prefer
2, 4, 6 or any other != 8 width?


I guess we could use tabs only at the line start, for indentation
only. Rather hard to implement, most text editors can't do that yet.


You mean for split lines? Hopefully there won't be that many, so there
is just to delete the tabs it added and replace it with spaces.

IMO, tabs SHOULD be used for syntactic indentation and spaces for
decoration purpose only. I.e. a line should start with a number of tabs
equal to its nesting level and after that only spaces should be used.
for example, the following code

for (i = 0; i < n; i++) printk("a very long format string", some, parameters);

should be formatted like this:

<tabs...>for (i = 0; i < n; i++)
<tabs...><tab>printk("a very long format string",
<tabs...><tab> some, parameters);

this will show exactly right regardless of your editor's tab expansion setting
as long as you use fixed-width fonts - where the screen width of the space character
is equal to all other characters. Once you start using tabs instead of spaces
to push text right so it appears exactly below some other text on the line above
you make a dependency on *your* editor's tab expansion policy and that's not very
considerate for folks who prefer a different one.

Don't know what to say more then: Yup! :)

But the CodeStyle-document and checkpatch.pl does not agree with that.


I know :(
If there's enough interest I can take a stab at seeing what it'd
take to implement such a check in checkpatch.pl

Benny

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



Relevant Pages

  • 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)
  • Re: reformat to tool/editor-compliant C style?
    ... convert 0x09 into whatever tabspace you've defined in your editor. ... anywhere that the code was written with tab-width 4. ... If someone writes this with tab-width = indentation = 4, ... no. *remove* all the tabs. ...
    (comp.lang.c)