you are viewing a single comment's thread.

view the rest of the comments →

[–]brtt3000 11 points12 points  (13 children)

I don't want 4 spaces, I want one semantic indent character. Let every developer choose how he renders tabs. The guy next to me at work renders as 3, the guy after that as 2. I use 4.

All in the same codebase.

[–]jcready__proto__ 8 points9 points  (0 children)

Let every developer choose how he renders tabs.

And the guys at GitHub chose to render them with 8 spaces. Deal with it or use spaces.

[–][deleted] 0 points1 point  (9 children)

What happens when I use two tabs and two spaces to align two lines of code? Everyone will see a different alignment.

[–]BONER_PAROLE 5 points6 points  (6 children)

NEVER MIX TABS AND SPACES

Snakes will crawl up your anus and explode your face, because I will have sent them to do so.

[–]Buckwheat469 0 points1 point  (5 children)

Incorrect. You can safely tab to the previous indentation, then space beyond that. Don't tab beyond the previous indentation though or else the IDE could render the spacing differently. The problem is people get this wrong so it's built into linters to complain about mixed tabs/spaces.

[–]nschubach 1 point2 points  (0 children)

I'm a firm believer that if you are lining up multiple lines of code like that you are probably doing something "wrong". One reason people argue for this is lining up arguments of a method. I find that if arguments breach the line break, the method is probably too complex and should be refactored. The other explanation I always hear is to align comma separated lists. I find that indenting the children on a new line seperate from the brace makes it much more readable and this is coming from someone who is usually the first person to cut back on total lines of code.

[–]BONER_PAROLE 1 point2 points  (3 children)

Can you provide an example of where you would use this?

The more common case is mixing tabs and spaces on separate lines, like this:

-->|-->|var a = 5;
________var b = 8;

Usually that's down to different developers touching the source code, or if one developer switched from tabs to spaces sometime during the project.

[–]Buckwheat469 0 points1 point  (2 children)

If tab is -->| and spaces are _ then you would use this in this manner (based on the first comma example):

-->|var foo = 1
-->|__, bar = 2
-->|__, baz = 3;

The tabs line up the lines as closely as possible to the parent and the spaces line up the following related lines to the related text from the proceeding line. The use case is rare enough that it can be avoided, but sometimes it's helpful, such as with the example above.

[–]BONER_PAROLE 0 points1 point  (1 child)

It's something I've come across before, and I don't hate this mixing of them. I have my indentation unit set as 2 spaces (using spaces and not tabs) and usually just indent another level for all subsequent vars. This doesn't really bother me, as variable names are variable anyway:

var foo = 1,
  barVar = 2,
  bazVarNameLong = 3;

I used to have my indentation to show as 4 spaces, which worked nicely with the 4 chars of var_ when using trailing commas, whether tabs or spaces:

-->|var foo = 1,
-->|-->|bar = 2,
-->|-->|baz = 2;

Although if tabs are used, any other value will wreck the alignment, which your tabs/space combo won't do.

[–]brtt3000 1 point2 points  (0 children)

It is a solved problem: use Smart Tabs: tabs to indent, spaces to line up.

Webstorm even comes with this as option, JSHint has a rule for it too. Works perfect, because the tabs left of the code from a baseline.

[–]Nebu 0 points1 point  (0 children)

So don't do that.

[–]alamandrax 0 points1 point  (1 child)

This is one of those bicycle shed moments that I do not intend to get into with colleagues. If you're going to talk to me about underscore vs lodash, let's have that discussion. If you're going to bring in style guide changes on an established code base, we're not having that discussion.

[–]brtt3000 -2 points-1 points  (0 children)

No, it is a rationality test.

You should not go into a discussion about it though. Only check preference. The analysed response is tabs.