Tabs are nice, but you are never sure are there some spaces or tabs, until you check. Also some tools handle indentation trimming differently than others, which is confusing.
Or⦠just take a deep breath, a little yoga, and move on with your life. I know, itās not that easy. But readers, please donāt mistake an obsession with whitespace with being a good coder (Jeff, I know you arenāt making that argument).
Iāve been coding for years. Wrote a couple of books on the subject. And this has never, ever bothered me. I run the code cleanup plugin in the IDE occasionally and am absolutely fine.
I also dislike terminal whitespaces, but I didnāt see the point of saying āOH MY GOD!ā I tried for a long time to see in which way those spaces would break the code. That would be the only thing that would cause such an outrage.
As I said I also dislike them, and I delete them whenever I get the opportunity, but with source control diffs that can ignore whitespace I donāt see it like a big problem and have learned to live with it (especially in a bigger team where some are not that concerned about it).
I think that caring about extra [trailing] whitespace is a little bit OCD-wise. But Iām guilty as charged
On the other hand, I find that a little bit contradictory: yes, itās wasted bandwitdth, but so is the one spent on tabbing tags. I suppose the correct OCD solution would be to strip all of the superfluous whitespace.
I guess thatās why my editor has a function to strip white space off the ends of lines. Ultraedit 32. But I donāt have a key assignment for it. Not that thereās much that I need to do with that, itās usually the data that I use that on.
GitX (http://gitx.frim.nl/) highlights end-of-line whitespace, so as long as Iām paying attention, I can catch it before itās committed.
At first I honestly did not see what was wrong, but after re-reading and learning of the mistake, I felt dirty, violated and wrong.
Off with the extra spaces.
Check out the built in macro in VS Samples->VSEditor->FixLineEnds - might just be what you are looking for!
Whatās the big deal? It might be a remnant of removed comment.
Completely harmless and irrelevant.
Iām just cheering that you indent with spaces rather than hard tabs. That way when I try to maintain your code, it looks consistent no matter which tools I use.
I couldnāt agree more!
What you need in your settings is, replace tabs with spaces, and a tab spacing of 2 or 4 (I used to use 4, but with web pages that can push it too far out).
Tab spacing of 8 is very 1970ās assembler!
Otherwise, the formatting depends on what tools you view the source in, which can seriously mess up the alignment.
I let emacs silently remove trailing whitespace on every save:
(add-hook 'before-save-hook 'delete-trailing-whitespace)
Yes, my diffs are occasionally larger than necessary, but thatās not my fault, itās the guy before me who left all that garbage in the file.
And once I had a multi-line C macro in a header file with CRLF line endings. Compiling on Solaris, only the CR was escaped, leaving LF intact and breaking the macro. Took several pairs of eyes before we figured out why the macro was breaking the compilation in strange ways.
Trailing whitespace breaks our product builds all the time because C compilers donāt treat it portably in multiline #defines. Some compilers object to space after the continuation characters ā\ā, and others let it fly, allowing a build break on a different platform build. This topic causes a suprising amount of grief. Some people configure their editors to remove it, but since everybody doesnāt do so, it can easily muck up version control systems that have merge capability.
āImagine how it is for those of us who spend a lot of time in Python world, where the whitespace isnāt just an OCD obsession, but can actually modify the functionality of code!ā
this is why whitespace is evil.
Think of all the wars that could have been avoided if python didnāt require tabs!
Weird how Jeff thinks he speaks for all programmers.
I donāt like to be filling my screen with even more characters, but one handy trick is to set the āvisible whitespaceā character color to your background color.
Most of the time itās invisible, but select the text and it pops out.
People, it is time for all of you to discover the Tab-key.
āthis is why whitespace is evil.
Think of all the wars that could have been avoided if python didnāt require tabs!ā
Python doesnāt require tabs ā it requires tabs OR spaces. The number of spaces is irrelevant so long as it is consistent.
Python and whitespace is NOT evil because it demands you pay attention to levels of indentation (GOOD) thus the readability of the code, to humans and to the parser, is guaranteed. Debugging is therefore very easy.
Trailing space is irrelevant. Any programming paradigm that still pays attention to space or tabs after a statement (unless of course its quoted) is a ridiculous hack and should be consigned to the dustbin.
I know Iāll get flamed for this, but VB5 and QuickBASIC both remove whitespace at the end of lines AND they also convert tabs to spaces.
Yes, I actually use both languages to do serious work.
Ctrl+A, Ctrl+E+C in Visual Studio takes care of those pesky, non-conforming outsider characters along with other formatting gaucherie.