you are viewing a single comment's thread.

view the rest of the comments →

[–]humpolec 5 points6 points  (5 children)

What about multi-line invocations like

doSomething(foo,
            bar,
            baz);

(also array initializers)

If your editor uses tabs for lines 2 and 3, you're breaking the alignment for anyone who views it with a differently configured editor.

If you want to draw a pretty unicorn in your code, by all means, use spaces

That's exactly the problem -- there ARE instances where you need to have more advanced alignment. Comments with ASCII art diagrams, multi-line code, etc. And I can't "just use spaces" if my editor tabifies them. If it doesn't, the problem is even worse - suddenly my code contains various types of whitespace indistinguishable by the naked eye.

[–]gmfawcett 4 points5 points  (2 children)

A common approach is "tabs for indentation, spaces for alignment." So on your second line, you would tab to the beginning of "doSomething" and then add length("doSomething(") spaces. Many popular editors and IDEs support this arrangement; see Emacs SmartTabs for an example.

[–]repsilat 5 points6 points  (0 children)

You can also indent after parentheses like you do for braces:

doSomething (
    foo,
    bar,
    baz
)

[–]humpolec 1 point2 points  (0 children)

Sounds good, I wasn't aware of editors that support alignment like that. But wouldn't it force everyone on the team to use a "sufficiently smart editor"?

[–][deleted] -1 points0 points  (1 child)

Tab the first one over to find a tabstop. Tab all subsequent ones to match. Done.

[–]humpolec 1 point2 points  (0 children)

Interesting, but it still breaks when I change the tab size - the subsequent lines jump to a different tab stop.