Four instead of eight spaces for tabs

Pages: 12
Does anyone else here think that this website displaying tab characters as eight spaces in code looks really bad?

For instance:
1
2
3
4
5
6
7
8
9
10
#include <iostream>

int main()
{
	for (int i = 0; i < 10; ++i)
	{
		if (i != 5)
			std::cout << "Hello world!\n";
	}
}

I think that if tabs were displayed (or automatically converted into, or otherwise) four spaces instead of the eight spaces that it is currently, it would look much better:
1
2
3
4
5
6
7
8
9
10
#include <iostream>

int main()
{
    for (int i = 0; i < 10; ++i)
    {
        if (i != 5)
            std::cout << "Hello world!\n";
    }
}

I know everyone probably has different indentation preferences, but I think four spaces looks at least decently okay (and is the default on most IDEs, I believe).

Any thoughts, comments, or opinions?

500!
There is a CSS style attribute to set the tab width - for instance, in Google Chrome, press F12 to open the developer console, and in the bottom right in the CSS style, add tab-size: 4 or any number and watch as it dynamically adjusts the size of tabs on the page.

All we would need is a Chrome Plugin (that I could never figure out how to write myself) or for twicker to change the CSS.
A standard tab is 8 spaces.

People who like to goober with them also seem to like to goober them for other people -- and I don't know why.

I see no reason for twicker to take time to mess with it for some people's oddball preferences.
@Duoas: My 1600x900 screen is only a tenth as wide as your screen, so if tabs are 8 characters the code goes off my screen very quickly. I don't think you should bias toward yourself just because you can afford a 16000x9001 screen and other people can't.

And if you were trying to start a tabs vs spaces war, I can't believe that from you. You should know to let people have their preferences.
Last edited on
Your responses are growing more and more childish.

People can have their preferences. They can even change them as you have suggested for Chrome, or using GreaseMonkey for FF.

But you are arguing that we should ignore everyone else's preferences in liu of yours.

A standard tab is 8 spaces.

And has been since the days of 80-column text displays.


On a related derailment, I want to buy a projector so I can have a wall-sized monitor.

Because, obviously, the bigger the monitor the more tabs I can get across it -- I won't have to resort to bitty-pixel fonts anymore.
obviously, the bigger the monitor the more tabs I can get across it
Well... no.
I think you'll have a hard time finding a projector with a higher resolution than 1080p.
> People who like to goober with them also seem to like to goober them for other people
¿what's to goober?
I've got peanut, or idiot.


> so if tabs are 8 characters the code goes off my screen very quickly.
Your line width should be around 65 characters for an easy reading.
This is one of the reasons I always de-tab my source code, or set the editor to insert spaces for tabs automatically. Some people like 2 space indentation, should they be required to make line widths short enough for people who like 8 space tabs, how about 16 space tabs!

It's my code, you will read it how I intend for you to. Don't like it, then find a reformatting tool.

Besides, 8 space indentation is just crazy IMHO. I honestly think 3 spaces would be ideal if it weren't so non-standard. I also think your hair looks ridiculous.
Last edited on
> People who like to goober with them also seem to like to goober them for other people
¿what's to goober?
I've got peanut, or idiot.


I am also confused. I believe he means to mess around with though.

I also think your hair looks ridiculous.

???

Does anyone else here think that this website displaying tab characters as eight spaces in code looks really bad?

For me I can't even tab in the message. Tab key's and Ctrl+I simply do not work. It could just be Google chrome though.

The standard for horizontal tabs has always been 8 why change now?
If it ain't broke, don't fix it.
long double main wrote:
Does anyone else here think that this website displaying tab characters as eight spaces in code looks really bad?

Yes, and I think the same in general, which is why I always insert tabs as four spaces (instead of merely changing the tab size in my editor).

I understand that a tab of size eight makes sense for command prompts, but in the case of source code it's a waste of horizontal space in my opinion.
I agree that it looks better in 4 spaces, I normally just use 4 spaces for my tabs anyway. However, I don't think that the tab sizes on this forum should be changed, rather, just promote the use of spaces instead of tabs. That way tabs get a consistent look and feel, as a tab should be 8 spaces.
I think it's a good idea as long as CSS is used because I prefer to get the tabs copied when copying code.

Why not make the tab width a setting so that each member can use the tab width he prefers?
Just threw in an update for my Chrome extension, didn't think of a CSS style for that.
https://dl.dropboxusercontent.com/u/83943521/publicaccess/Files/CplusplusQuoteButton.crx

Install:

Go to chrome://extensions/
Drag the .crx file in that page

Note: It will automatically update the older extension, no need to uninstall that.
helios wrote:
I think you'll have a hard time finding a projector with a higher resolution than 1080p.
Oh no! My dreams smashed by cold, hard reality!

ne555 wrote:
¿what's to goober?
I've got peanut, or idiot.
I prefer peanut, because it is tastier and, surprisingly, easier to clean off. Of course, idiot has the advantage that other people seem to have a difficult time noticing it.


I never use hard tabs. Two spaces is natural enough for any touch-typist. For code I get from people who like to mix and match oddly-sized tabs and spaces (nearly unavoidable) there are simple pretty printers like AStyle.

One of the reasons I persist in using my ancient text editor is because it is smarter than most modern editors when handling soft tabs.
NT3 wrote:
I don't think that the tab sizes on this forum should be changed, rather, just promote the use of spaces instead of tabs.


This.

I still don't understand how people prefer hard tabs.
It's not uncommon to open up a file which is tab-delimited. It's used because it's likely that the columns will remain aligned if the items are expected to be a similar size. However, when sharing such a file around an entire department, things will easily get mis-aligned and people will use various editors which display tabs in various widths. Everything gets quickly mis-aligned anyways.

I like to stick to spaces, but there is nearly no way to enforce that.

Oh and: http://m.xkcd.com/1301/.
xkcd wrote:
I've never been lied to by data in a .txt file which has been hand-aligned.
@Duoas: I would not have ever expected you of all people to be so closed-minded. So some arbitrary tab-size decided upon years ago has to be the way tabs are forever?

I use tabs instead of spaces because people can choose how wide they want the indentation to be without mucking up formatting with a formatting tool. So you can very easily view all my code in 8-spaces per indentation level if you so require it.

Oh, and I definitely don't want to argue tabs vs spaces - I'm just explaining why I use tabs to those of you who prefer spaces.

Duoas wrote:
Your responses are growing more and more childish.
I used to look up to you.
I use tabs instead of spaces because people can choose how wide they want the indentation to be without mucking up formatting with a formatting tool. So you can very easily view all my code in 8-spaces per indentation level if you so require it.

I would say that since it's your code anyway and you thus implicitly enforce your coding style unto the reader, you might as well enforce your indent style along with it.

It's annoying when code is automatically uglified just because the original author used a different tab size setting than you do.

And you have to be very careful to successfully write tab-size agnostic code which is pretty regardless of tab settings. You can forget about splitting up if() conditions onto multiple lines, among other things.
Last edited on
ne555 wrote:
Your line width should be around 65 characters for an easy reading.

I use 120 character lines. I used to use the standard 80 but programmers these days tend to use graphical displays that can fit far more than 80 characters on a line. It's not my problem if they're stuck in the past. I mean, I could fit at least 200 characters on a line if I were so inclined, but I think stopping in the middle is nicer.

That said, I stick to 8-space tabs because it's a standard. It doesn't make a difference what the standard is, be it 2, 4, 8, 16, 32, whatever. It's just important that there's some standard so that there's some consistency. If someone wants to change it to something else, that's his call, but you shouldn't complain that something doesn't look right when you ignore standards, even if they are de facto ones.

@Stewbond
I only just now discovered that xkcd comics have tooltips, because when I clicked your link, the tooltip text came up just before the image loaded on top of it. If not for that random error, who knows how long it would have been before I had found out about the tooltips?
Last edited on

you shouldn't complain that something doesn't look right when you ignore standards, even if they are de facto ones.


I'd argue there is no de facto standard for tab width.

Case in point, the 2 editors I use the most (Notepad++ and MSVS) both default to 4 space tabs... not 8. MS Word and other word processors don't even correlate tabs to a fixed number of spaces, but instead correlate to the nearest inch/measurement marker.

Tabs are inconsistent by their very nature. Which is why I avoid them. If you want your code to look the way you want it... then you pretty much can't use them. Spaces look right on any monospaced font. With tabs... you never know what you're going to get.
Pages: 12