Am I TRWTF for this?
-
So... I'm working in PHP. Whitespace is generally irrelevant (it's not if you're caring about pretty-printing HTML as output but outside of that)
And I keep finding trailing whitespace, where I've just been untidy with the editor. I'm talking about cases where Notepad++ has carried on the indenting at the same tab-depth as the previous line but I have blank lines for readability and delineating code chunks (along with healthy amounts of comments)
But is it CDOish to go through and search for
/\s+$/
and then remove the spaces that shouldn't be there?
-
But is it CDOish to go through and search for /\s+$/ and then remove the spaces that shouldn't be there?
Yes.
-
Next question then, is it a bad thing?
-
I hope not. I've done it myself occasionally.
-
-
-
The guy I was hired to replace where I work now was almost aggressively indifferent to indentation. I'm pretty sure it's actually random. He was big on trailing whitespace. I fix it when I see it.
He Also Formatted All His Error Messageboxes Like This which gets right up my nose.
-
I hope not. I've done it myself occasionally.
Next question then, is it a bad thing?
-
Control-K, D
-
hmm
-
Yes, use a free online formatter.
-
-
I fervently disagree
-
Personally, I like keeping blank lines indented to the same level as the previous line.
trailing whitespace I only tend to remove when I'm modifying that line or those around it. It annoys me, but not as much as the extra changes in diffs (I know you can ignore whitespace changes but it still irritates me)
-
Ooh, I've finally experienced the whole "not sure if your post was actually posted" bug. I feel like I've arrived
-
Personally, I like keeping blank lines indented to the same level as the previous line.
Same here.
-
I have the following in my
.vimrc
:" - Remove trailing whitespaces and ^M chars autocmd FileType c,cpp,java,php,js,python,twig,xml,yml \ autocmd BufWritePre <buffer> \ call setline(1,map(getline(1,"$"),'substitute(v:val,"\\s\\+$","","")'))
I don't like trailing whitespace on lines with actual content, but I have no strong opinion on leaving indentation on otherwise empty lines.
I can see some benefits in both approaches, I guess.The above substitution could be easily adapted to leave indented empty lines alone.
-
Step 1: Use tabs like a man.
Step 2: Find a good IDE.
Step 3: Let the IDE take care of that shit for you
Step 5: Profit
-
Step 1: Use tabs like a man.
How does that help with trailing whitespace? You'd just get trailing tabs instead?
-
How does that help with trailing whitespace? You'd just get trailing tabs instead?
- There are 2 or 4 times smaller characters to manage
- It makes you feel more awesome, thus have more energy to fix the whitespace issues
- I was just being a dick
-
-
Fixed
-
Also, 8 space tabs FTW. Or even 16 if you're feeling really fancy. Why not use your widescreen monitor to its full capability?
-
Also, 8 space tabs FTW. Or even 16 if you're feeling really fancy. Why not use your widescreen monitor to its full capability?
Because my widescreen monitor is rotated 90Β°, making it a tallscreen monitor ;)
-
I have the following in my .vimrc:
so do i!
i also have syntastic installed so i get automatic lint checks
i never leave home without it
-
i never leave home without it
Funny. I consider pants to be a higher requirement for leaving the house.
-
right... outside is a pants required zone...
i never leave home without it (and pants)
-
What is that outside thing I keep hearing about so much lately on Twitter?
-
What is that outside thing I keep hearing about so much lately on Twitter?
i think it's related to this
Life
thing i hear you can buy on Amazon now.
-
eldelshell@eldelshell-laptop:~/git/jobhunter$ man life
No manual entry for lifeOh well, at least I tried!
-
-
Aaaah.... the glider gun...
Conway's Game of Life, good for hours of.... well staring at an interactive lava lamp really... but it's fun! i swear!
-
Personally, I like keeping blank lines indented to the same level as the previous line.
trailing whitespace I only tend to remove when I'm modifying that line or those around it. It annoys me, but not as much as the extra changes in diffs (I know you can ignore whitespace changes but it still irritates me)
+ࡧ
THIS. So much this.
-
Step 2: Find a good IDE.Step 3: Let the IDE take care of that shit for you
IDEs just aren't smart enough to do this to my satisfaction.
-
Why are you giving jaloopa a virtual tampon? That is one special character.
-
I thought it was a chu chu rocket
-
Never played the original, though, only the iOS version. And that was a long time ago.
-
IDEs just aren't smart enough to do this to my satisfaction.
Yeah, I suppose. They get the job done to a certain extent, but then there's always that one special case for which there's no option and that you have to micro-manage by hand. That's why the tabs thing - they make it so much easier to manipulate the whitespace.
-
Ooh, I've finally experienced the whole "not sure if your post was actually posted" bug. I feel like I've arrived
When his post didn't appear, Discourse dropped the jaloopa.
-
Step 1: Use tabs like a man.
Your heterodoxy must be crushed!
"My opinion is that the best way to solve the technical issues is to mandate that the ASCII #9 TAB character never appear in disk files: program your editor to expand TABs to an appropriate number of spaces before writing the lines to disk."
-
-
"My opinion is that the best way to solve the technical issues is to mandate that the ASCII #9 TAB character never appear in disk files: program your editor to expand TABs to an appropriate number of spaces before writing the lines to disk."
I might agree if he agrees to only do this via regular expressions.
-
I might agree if he agrees to only do this via regular expressions.
I'll not be trolled into his quote about that. Not here, not today, sir!
-
Not caring about how your code looks is unprofessional. Every time I run into code with mixed spaces and tabs and random trailing whitespace, it's bad code. The urge to clean it only shows that you know that clutter is the enemy of readability.
Also, most sane editors won't leave this kind of garbage and it complicates source control diffs. Anyone who tolerates white space messiness is obviously using neither properly.
-
Notepad++
Edit > Blank Operations > Trim Trailing Space
I actually have a macro that does that prior to saving. Talk about OCD...
-
I am perhaps TRWTF for being distrustful of such things
-
Personally, I like keeping blank lines indented to the same level as the previous line
You're a terrible person.
-
Not caring about how your code looks is unprofessional.
THIS! Readability is number one concern when writing code. Maybe number two, after "it works". Three, after "fast enough". Okay, it's not number one but it's up there somewhere.
-
Readability is number one concern when writing code.
not not really(you admit as much actually) i'd personally order them this way
- It works correctly
- It has a robust enough error handling (how much is enough will vary depending on what is being built and why)
- It is performant and has capacity to scale up(if needed) without major redesign.
- It is maintainable by others (there is a minimum level of code formatting here, but it's not as strict as later)
- It is sufficiently documented (both for tech and non tech. as with 2 will vary from project to project)
- It is "pretty", follows all the nice design patterns, maybe even passes the relevant lint checks without warnings. (here's the rest of the readability stuff)
so as you can see in my list readability is split between items 4 and 6 on the priority list.
It might not be the best list, it might not even be a particularly correct list, but it is my list and it has served me well these last 12 years.
-
I move "It works correctly" lower on the list. Every member on the team already has this on their checklist, but the developer is the only one that can take responsibility for maintainability.
Putting "works correctly" as number one is a recipe for making compromises. I would rather tell the team that something can't be done in the required amount of time than hit a deadline with an unmaintainable mess.