Whitespace!

24 views
Skip to first unread message

Kristján Pétursson

unread,
Feb 6, 2012, 8:02:48 PM2/6/12
to Singly Developers
The initial frontier...

Whitespace is inconsistent among and even within TLP's files. I'm not going to push any particular standard, but if we want to pick one, it would relax me to tell Vim about it and make everything conform as it gets touched.

For sake of starting point, I propose 2 space indents/no tabs for all filetypes.

Matt Zimmerman

unread,
Feb 6, 2012, 8:15:57 PM2/6/12
to singl...@googlegroups.com

I usually prefer 4 space indents, but Node does seem to make for a lot of
nesting (though maybe that's a bug?).

At any rate, I agree we should standardize and I don't feel strongly about
what the standard should be. I'll support whatever happens.

--
- mdz

Kristján Pétursson

unread,
Feb 6, 2012, 8:23:02 PM2/6/12
to singl...@googlegroups.com

On Mon, Feb 6, 2012 at 5:15 PM, Matt Zimmerman <m...@singly.com> wrote:
I usually prefer 4 space indents, but Node does seem to make for a lot of
nesting (though maybe that's a bug?).

Yeah, Simon mentioned that when you're starting at column 40, maybe you should refactor.


Found this:

Simon Murtha-Smith

unread,
Feb 6, 2012, 8:47:04 PM2/6/12
to singl...@googlegroups.com
On Mon, Feb 6, 2012 at 17:23, Kristján Pétursson <kris...@singly.com> wrote:
Found this:

On a first pass, I feel like I could support nearly everything in this doc. Wooo!

Jeremie Miller

unread,
Feb 6, 2012, 9:05:04 PM2/6/12
to singl...@googlegroups.com, singl...@googlegroups.com
Ditto!

Thomas Muldowney

unread,
Feb 6, 2012, 10:43:09 PM2/6/12
to singl...@googlegroups.com
I audibly groaned at 2sp tabs, but if we're picking something, let's make it consistent.

--temas

Forrest Norvell

unread,
Feb 7, 2012, 12:09:41 AM2/7/12
to singl...@googlegroups.com
I'm also a fan of 4 spaces, and am finding that I'm actually not doing too much excessive indentation now that I've switched to the error-handling style I documented in my little note yesterday (and breaking more of the nested functions out into their own functions).

Same goes for CSS / LESS.

I'm completely down with 2-space indents in HTML / XML, though. You can't exactly refactor HTML to break out the indentation.

F

Kristján Pétursson

unread,
Feb 7, 2012, 6:32:41 PM2/7/12
to singl...@googlegroups.com
I'm completely down with 2-space indents in HTML / XML, though. You can't exactly refactor HTML to break out the indentation.


Oh yes you can! Partials FTW!

It seems we're 3v3 on 2 spaces vs 4, which tells me it won't actually matter which we pick. Does anyone feel strongly and/or want to make an argument for one way?

On the side of 2
- The Node community picked it
- 4 is a waste of screen real estate :-p

Out of curiosity, why would you want 4 spaces in JS and 2 in HTML? Not understanding any real reason for one or the other, I definitely don't see why different filetypes warrant different spacing.

Chris Burkhart

unread,
Feb 7, 2012, 6:39:06 PM2/7/12
to singl...@googlegroups.com
For what it's worth, while I've always been a 2 space guy, I found that I preferred node having 4 spaces because it helped me catch myself when I was wandering too deeply into spaghetti callback hell.

If it wasn't a hassle to switch VIM constantly between 2 and 4, I'd say 4 for node, and 2 for everything else.

Jeremie Miller

unread,
Feb 7, 2012, 6:45:51 PM2/7/12
to singl...@googlegroups.com
My only *sigh* is that a one-time switch you loose all git line history in the entire codebase :(

I've been through so many styles I've lost all religion on it, but the overall theme I've gleaned has been that real tabs give the coder the most choice at the "edge" (is the only problem with that being then if someone's editor starts checking in spaces unknowingly as it's easy to miss visually?) but I'm still pretty meh, whatever works!

Jer

Forrest L Norvell

unread,
Feb 7, 2012, 6:47:54 PM2/7/12
to singl...@googlegroups.com, singl...@googlegroups.com
JavaScript is code and the extra white space is pleasing to my eyes. Same reason I like angry fruit salad highlighting schemes. Less white space makes more sense for documents, especially when you have to visually filter out angle-bracket chunder anyway.

That said, I don wanna fight nobody bout it. Life's too short.

F

PS -- The Go community has standardized on hard tabs of 8 space tab stops. Vim and ftplugin are my friends.

Sent from my iPhone

Kristján Pétursson

unread,
Feb 7, 2012, 7:31:06 PM2/7/12
to singl...@googlegroups.com
@Chris - some .vimrc magic for you
autocmd Filetype javascript setlocal tabstop=4 shiftwidth=4

@Jer - losing line history makes me sad too. But it's not really lost, just masked. Like network failure and TCP.

Here's another approach - polling time!

2012/2/7 Forrest L Norvell <for...@singly.com>

Chris Burkhart

unread,
Feb 7, 2012, 7:34:44 PM2/7/12
to singl...@googlegroups.com
Yeah, I just meant between node + frontend, vim treats it all as javascript.  It was especially annoying alternating between locker project stuff and other things I was working on, because everywhere else my javascript is set to 2 spaces.

Is there a way to determine filetype based on directory or something similar in vim?

Kristján Pétursson

unread,
Feb 7, 2012, 7:41:43 PM2/7/12
to singl...@googlegroups.com
On Tue, Feb 7, 2012 at 4:34 PM, Chris Burkhart <ch...@singly.com> wrote:
Yeah, I just meant between node + frontend, vim treats it all as javascript.  It was especially annoying alternating between locker project stuff and other things I was working on, because everywhere else my javascript is set to 2 spaces.

Is there a way to determine filetype based on directory or something similar in vim?

Ah, gotcha. There's surely some way to do that, but it might be with an arbitrarily complicated plugin.

I had the thought to set up hotkeys to switch modes, and someone has here (down in the comments):

And then I thought wouldn't it be cool if Vim cascaded .vimrc the way Git cascades .git/config, and bam!

ID 441...it's like people have had this problem for a while. For curiosity's sake, here's the first real Vim script ever (the first three are examples):

Chris Burkhart

unread,
Feb 7, 2012, 7:49:37 PM2/7/12
to singl...@googlegroups.com
Yeah, I had hotkeys, but kept forgetting them and just typing in the ':set ts=2 sw=2' stuff every time.

That cascading .vimrc plugin looks super handy though and a much cleaner way to handle this.

Thanks!

Beau Gunderson

unread,
Feb 8, 2012, 5:58:43 PM2/8/12
to singl...@googlegroups.com
You could also do something in ~/.vim/ftdetect like:

au BufNewFile,BufRead */Locker/other_path/* set filetype=node
au BufNewFile,BufRead */Locker/some_path/* set filetype=javascript

(and have your file types setup in ~/.after/ftplugin/{node.vim,javascript.vim})

That said, I like everything in that nodeguide.com style guide (especially the bit about separating if statements from their bodies so that they're on separate lines)

For HTML I've always used 1 space (because the angle brackets line up nicely).

Kristján Pétursson

unread,
Feb 10, 2012, 12:32:53 PM2/10/12
to singl...@googlegroups.com
Alright, because we're split down the middle, nodeguide says it, it simplifies configs, and hell, I prefer it, I'm calling the fight at 2 spaces everywhere. Speak now or forever hold your space.

Beau - just tried an HTML file on 1 space and I could get use to it. Right now it's like I'm looking at a graph at the wrong scale. I do like how all the closing tags draw a line.

Forrest L Norvell

unread,
Feb 10, 2012, 12:42:13 PM2/10/12
to singl...@googlegroups.com, singl...@googlegroups.com
I admire your bold call more than I care about spacing. I'll update my vim settings forthwith.

F

Sent from my iPhone
Reply all
Reply to author
Forward
0 new messages