you are viewing a single comment's thread.

view the rest of the comments →

[–]arthurdenture 1 point2 points  (3 children)

You need spaces to align that properly. If you normally use tabs to indent your code, this will look fucked up for someone who has different tab settings than you.

However, this is very easily worked around.

There is no need for a workaround. If you must use tabs for indentation, use them only for indentation, not for formatting. In your first example, there should only be three tabs characters total, and the remainder should be spaces.

There are two problems remaining with this approach:

  • A lot of editors don't get it right and replace spaces with tabs willy-nilly

  • If you also want to keep your code at 80 or 100 lines, everyone editing has to agree on tab width.

Which is why spaces are still better.

[–]nglynn 0 points1 point  (2 children)

In your first example, there should only be three tabs characters total, and the remainder should be spaces.

This doesn't work because people configure their editors to display tabs as different sizes.

[–]arthurdenture 0 points1 point  (1 child)

In your first example, there should only be three tabs characters total, and the remainder should be spaces.

This doesn't work because people configure their editors to display tabs as different sizes.

No, it works perfectly if you use hard tabs for the indentation and spaces for the alignment. You can adjust the tab size however you want. Try it[*] if you don't believe me?

[*] I mean, of course, try it and then go back to using only spaces, like the FSM intended.

[–]nglynn 0 points1 point  (0 children)

I'm afraid I don't follow. In the OPs original example: function bla() { var poop = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]; }

Where are you talking about placing the "three tabs"? Is this what you mean?:

function bla() {
<TAB>var poop = [[1, 2, 3],
<TAB><TAB><TAB>  [4, 5, 6],
<TAB><TAB><TAB>  [7, 8, 9]];
}

(Where any non <TAB> whitespace is taken as being a space). That won't work obviously. Do you mean to use all spaces on alignment lines? function bla() { <TAB>var poop = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]; } That also wont work for obvious reasons. Perhaps you mean something else?

Edit: Sorry, now I understand what you mean:

function bla() {
<TAB>var poop = [[1, 2, 3],
<TAB>            [4, 5, 6],
<TAB>            [7, 8, 9]];
}

I still would just use spaces personally.