Page 1 of 1
Spaces in blank lines
Posted: Thu Jan 17, 2008 6:20 pm
by Ambush Commander
One of the more peculiar (to me) conventions I've encountered when browsing other people's codebases is the absence of spaces in blank lines. For example, where I would expect (spaces were replaced with periods):
Code: Select all
function foo() {
....doSomething();
....
....doSomethingElse();
}
I see...
Code: Select all
function foo() {
....doSomething();
....doSomethingElse();
}
Why is this the case? Part of the reason of my ignorance is the fact that my editor (Notepad++) automatically adds spaces when I make a new line, but if I press ENTER again, those spaces stay there. Do other editors work differently?
Re: Spaces in blank lines
Posted: Thu Jan 17, 2008 6:22 pm
by Inkyskin
I have noticed the same thing too - however I also use Notepadd++

Re: Spaces in blank lines
Posted: Thu Jan 17, 2008 6:31 pm
by RobertGonzalez
Not all editors maintain indentation. In fact, in many editors this feature is off by default. Notepad++ has a setting that will let you turn it off. I know vi and gEdit do not keep indentation. But it is a nice feature to have.
Re: Spaces in blank lines
Posted: Thu Jan 17, 2008 7:49 pm
by Zoxive
Everah wrote:I know vi and gEdit do not keep indentation.
Whens the last time you have used VI?
Mine keeps indentation, all though I use Vim/Gvim. (Mostly Gvim)
Another note, i have the crap hacked out of my Gvim.
My default config is 350 lines. <3 Full Customization/Custom Scripts.
Edit: Just checked more into it. Read the comment...
Code: Select all
----Function();
---- //Vim Removes These spaces after i go to the next line, while its still indented for the next line.
----Function2();
I actually like the way vi does it, mostly because there are sooo many ways to move around in vi. I guess then theres a little less data stored also. A little

Re: Spaces in blank lines
Posted: Thu Jan 17, 2008 7:55 pm
by Chris Corbyn
Quite annoying JEdit (the editor of choice in our office) removes any whitespace on blank lines, so here's me maintaining my indent profile, then hit CTRL + S and boom, JEdit blows it away.
I like to have the entire block indented, not just the lines with content on them. I'd be using TextMate at work if we didn't have to work off a damn samba share (TextMate dies painfully on samba shares

)
Re: Spaces in blank lines
Posted: Thu Jan 17, 2008 8:00 pm
by Jonah Bron
I use Dreamweaver or SciTE, and they both maintain indentation, content or no content.
Re: Spaces in blank lines
Posted: Fri Jan 18, 2008 9:24 am
by Jenk
Eclipse has the option to remove trailing whitespace. Ergo, it will trim the lines with nothing but whitespace back to just \n.