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).
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.
@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.
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.
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 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.
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.
@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 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.
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?
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.