Why I love having tabs in source code.
derkarl.org
derkarl.org
Srsly. When you're starting a brand new green-field project, you can indent however you feel like. But if you're working on an existing project, just do it the way the original person did it, even if it's not your favorite coding style. It's not worth the time and energy arguing over it. All this talk about ease of reformatting code is ridiculous...you shouldn't reformat code, you should just do what everybody else on the project does.
Apparently the author doesn't know about the -w option to diff, which makes it ignore whitespace.
I have found, in general, that it's the very new or very bad programmers that want to quibble over style. Everyone I've worked with is fine with anything. In the long run, it just doesn't matter at all.
Putting the correct thing in their .emacs usually clears things up (show-trailing-whitespace throws your loose whitespace habits right in your face).
Similarly, people are more productive when using the indentation style of their choice. I like 3 or 4 spaces of indenting, and I find using 8 spaces makes the code hard to read. Other people have different preferences. It seems to me that the best way to accomodate everyone on a multiple-developer project is to require that code is run through a formatting utility before being checked in, and to allow people to use similar utilities to format it when checking it out and editting it.
I have been working on cperl-mode's indentation recently, and think it gets indentation right in 99.9% of cases. If you encounter that 0.1% case, you should submit a bug report here:
http://github.com/jrockway/cperl-mode/issues
(Keep in mind that indentation is highly customizable, so you probably just need to flip some switches to get what you want.)
So this guy isn't pro-tab-only. He's in favor of mixing.
And I agree with you, that's just trouble.
Ohhh... Hardware Tab Expansion - the only way to expand for a true believer :-)
I agree with the article's rationale and use this practice for new projects. Nearly all the arguments I hear for spaces are 'Other people screw it up, so just go with spaces to accommodate them'. I think this is quite defeatist. Why not enforce the coding style of choice for a project with some check-in hooks?
:retab has helped on several occasions.
This article did not convince me to change my mind. (It did convince me that the author knows nothing about Emacs, like most Vim users.)
I think as you implement what the article describes, you will find it to be tedious and impractical in real-world use.
SomeClass::SomeClass()
_____.:.InheritingClass(false, false
_____...................5, 10, true,
_____...................bleh, blah)
As compared to SomeClass::SomeClass()
_____.:.InheritingClass(false, false
____________________....5, 10, true,
____________________....bleh, blah)
Which will no longer align if tabstops are changed.I've set up emacs to do the right thing in c-mode, and possibly in other modes which inherit from it. It's not hard to find a solution online, but it's certainly not "out of the box".
Would you mind posting a .emacs snippet? I've tried to do it in the past and got the impression it was not possible. I'd love to see what you did.
Which is a (very slightly) modified version of what I foud here: http://bytes.inso.cc/wp/2009/01/07/dot-emacs-smarter-indenta...
This seems to be a more language-agnostic approach: http://www.emacswiki.org/emacs/SmartTabs
I use tabs mainly from habit, but I think it helps keep consistent indentation (it's quite easy to be off by one space). Also, with my habit of using `h` and `l` for navigation, tabs mean fewer keypresses than spaces (I should use `w` and `e` I guess)
Also one of the best things you can can do to help avoid a lot of this frustration, is put those comments at the end of every source code file that configure indents for both emacs and vim. It makes switching between 4 and 8 space indents a bit less irritating.
I've been flirting around with a literate programming environment, and it's been far easier to use spaces with a traditional line measure - around 80 chars. The code can be included into HTML or print layouts with few edits. That seems to be the "easy to layout" setup.
I have a very simple policy on tabs: I don't use them. And since I've had that policy, I've never had a problem involving tabs.
As long as people are consistent, either way is fine.
Oh wait. That's right, I don't. Spaces all the way because tabs blow up some languages.