Spaces in blank lines

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Spaces in blank lines

Post 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?
User avatar
Inkyskin
Forum Contributor
Posts: 282
Joined: Mon Nov 19, 2007 10:15 am
Location: UK

Re: Spaces in blank lines

Post by Inkyskin »

I have noticed the same thing too - however I also use Notepadd++ ;)
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: Spaces in blank lines

Post 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.
User avatar
Zoxive
Forum Regular
Posts: 974
Joined: Fri Apr 01, 2005 4:37 pm
Location: Bay City, Michigan

Re: Spaces in blank lines

Post 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 :mrgreen:
Last edited by Zoxive on Thu Jan 17, 2008 7:59 pm, edited 2 times in total.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: Spaces in blank lines

Post 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 :()
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: Spaces in blank lines

Post by Jonah Bron »

I use Dreamweaver or SciTE, and they both maintain indentation, content or no content.
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Re: Spaces in blank lines

Post by Jenk »

Eclipse has the option to remove trailing whitespace. Ergo, it will trim the lines with nothing but whitespace back to just \n.
Post Reply