Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Why do people hate tab indents?

This thread is locked; no one can reply to it. rss feed Print
 1   2 
Why do people hate tab indents?
AMCerasoli
Member #11,955
May 2010
avatar

Say whatever you want. You'll never find a keyboard without a Tab key. 8-)

Let's scare some losers!

{"name":"keys-031.jpg","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/c\/a\/ca5aabc41f09ccbf7dbbef351861531d.jpg","w":640,"h":480,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/c\/a\/ca5aabc41f09ccbf7dbbef351861531d"}keys-031.jpg

Thomas Fjellstrom
Member #476
June 2000
avatar

Oh, I still use tabs. but set the indent width to 3 spaces. Saves as a tab, but displays as three spaces.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

AMCerasoli
Member #11,955
May 2010
avatar

I wasn't referring to you bro ;) but the "Others".

Chris Katko
Member #1,881
January 2002
avatar

bamccaig said:

Then surely you edit with white-space visible all the time?

You missed the most important part. Spaces are spaces. Tabs are tabs with a tiny, obvious tab marker in grey.

Look how obvious and imposing those evil tab markers are!

{"name":"kdev-kernel-3.png","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/6\/3\/63ef2259d0bd50cca2e6ebf254cdede2.png","w":757,"h":704,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/6\/3\/63ef2259d0bd50cca2e6ebf254cdede2"}kdev-kernel-3.png

If only they were spaces the code would become immediately more readable. ::)

Were you expecting something like this?

{"name":"1RgHzFX.png","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/2\/b\/2b47cb23489f0e7dff87f451550a45e5.png","w":757,"h":704,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/2\/b\/2b47cb23489f0e7dff87f451550a45e5"}1RgHzFX.png

-----sig:
“Programs should be written for people to read, and only incidentally for machines to execute.” - Structure and Interpretation of Computer Programs
"Political Correctness is fascism disguised as manners" --George Carlin

Thomas Fjellstrom
Member #476
June 2000
avatar

You end up with more markers with spaces. It's ugly. And if your editor also shows the indentation markers, you get both indentation and space markers which makes for a mess.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Matthew Leverton
Supreme Loser
January 1999
avatar

Tabs are awesome.

It's not really tabs vs spaces anyway. It's tabs vs 1 space vs 2 spaces vs 3 spaces vs 4 spaces ... I once worked with a guy who used 40 spaces. He literally hit the space bar 40 times. His argument was that it looked the same on everybody's screen. I couldn't really think of any counter arguments, so I guess he stumbled across the perfect setting.

Anyway, if you really must see X spaces per tab in a terminal, you can just pipe things through expand -t X.

Thomas Fjellstrom
Member #476
June 2000
avatar

I even set nano to display tab as 3 spaces. :D it helps save screen space too.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

bamccaig
Member #7,536
July 2006
avatar

Look how obvious and imposing those evil tab markers are!

Those markers are so subtle I imagine you could easily make mistakes even with those showing. What does it look like with indentation errors?

m c
Member #5,337
December 2004
avatar

kazzmir said:

There is only one true amount of indentation, which is 4 spaces.

I dispute this. It is 8, that is better for aligning things in a tabular layout. So, using tabs for fast editing, pressing / holding space is takes too long.

Also, if your editor saves tabs as spaces, then how do you write Makefiles?

(\ /)
(O.o)
(> <)

kazzmir
Member #1,786
December 2001
avatar

m c said:

So, using tabs for fast editing, pressing / holding space is takes too long.

I still press the tab key, my editor just puts in spaces.

set softtabstop=4
set expandtab
set shiftwidth=4

Quote:

Also, if your editor saves tabs as spaces, then how do you write Makefiles?

My editor knows to use real tab characters when editing makefiles*

*makefiles are primitive compared to cmake/scons so I rarely write makefiles in the first place.

m c
Member #5,337
December 2004
avatar

I see, I should have known.

I do use nocompat and syntax on but that is all.

I used to use indent but then it messed up pasted code too much for me.

I assume you use CMake for crossplatform support, like allegro itself does.

scons, ant, qbs, jam, gnatmake, cmake, custom shell scripts, non-gnu makes which don't support this or that, one true build tool to rule them all I have never seen.

But any developer can do it him/herself so long as they can see what files to build, what preproc defines to set, and what libs to link so I just keep it simple.

(\ /)
(O.o)
(> <)

bamccaig
Member #7,536
July 2006
avatar

m c said:

I used to use indent but then it messed up pasted code too much for me.

set pastetoggle=<F2>

Though I honestly rarely paste code... I don't believe in copying/pasting code... If the code is that similar then you should write it once in a reusable way... Which may not include some repetitive patterns in code, but I don't copy/paste those either. I yank/put them or macro/script them...

Here is a condensed (untested) version of my .vimrc:

.vimrc.min#SelectExpand
1autocmd! 2autocmd GUIEnter * simalt ~x 3filetype indent on 4filetype plugin on 5nmap <silent> ,/ :nohlsearch<CR> 6nnoremap j gj 7nnoremap k gk 8setglobal fenc=utf-8 9syntax enable 10 11set autoindent backspace=eol,start,indent cindent 12 \ fencs=ucs-bom,utf-8,latin-1 ffs=unix,dos,mac expandtab 13 \ history=9999 hlsearch mouse= nobackup nocompatible 14 \ noerrorbells nojoinspaces noswapfile nowrap nowritebackup 15 \ number pastetoggle=<F2> ruler shiftwidth=4 showmatch 16 \ smarttab tabstop=4 textwidth=74 whichwrap+=<,>,h,l

It's really not that long when you remove comments and join statements! I expanded the option names to make it a bit easier to infer what they mean, but you could make it even shorter with the short versions! I could probably make it a bit shorter too now that I'm experienced and no longer need the n00b helpers, but this file should be relatively friendly for beginners to start from.

The full thing with comments can be found on GitHub. When I have the chance I'd like to find a middle ground where comments are the bare minimum to understand everything. Much of the file came from third parties and was gradually added onto and tweaked (I recommend that same approach for vi[m] beginners).

 1   2 


Go to: