Vim: space or tab in indenting?

this is semi-off topic but still related to ror.

i had a problem with testing my depot program (which i follow the
tutorial in agile web development book). it took me many hours to solved
the problem. all the while i thought i was using spaces inside the
test/fixtures/products.yml

programmer_book:
id: 1
title: Pragmatic Programmer
description: Best book for the programmer
image_url: http://localhost:3000/images/pp.jpg
price: 29.95
date_available: 2006-05-01 00:00:00
^^ ^^^^

the culprit is there were tabs in my code, before the key (id,
title,…). replaced it with space and now my program/testing worked.

im using vim and i was thinking of changing my preferences on
tabbing/indenting. instead of tabs, it will insert spaces. but i want to
know if there are any implications on using space instead of tabs in the
code. thanks.

Hi

seems that (although I wasn’t aware of that) tab are prohibited under
YAML
(see YAML Ain't Markup Language)

cheers

malamute jute wrote:

im using vim and i was thinking of changing my preferences on
tabbing/indenting. instead of tabs, it will insert spaces. but i want to
know if there are any implications on using space instead of tabs in the
code. thanks.

In YAML, as has already been pointed out, tabs are banned. In code?
That’s a religious question, but I think the tendency among rubyists is
towards spaces over tabs, because you can’t guarantee the appearance of
indentation with tabs.

There is (as I understand it) currently an issue with RMagick on Windows
related to tabs in code, but that’s definitely a bug somewhere. They
should be interchangable.

On May 5, 2006, at 9:13 AM, Alex Y. wrote:

There is (as I understand it) currently an issue with RMagick on
Windows related to tabs in code, but that’s definitely a bug
somewhere. They should be interchangable.

You probably won’t run into this dealing with Ruby, but if you write
old fashioned Makefiles, they require tabs. And if you use spaces
in your make rules, it gives a rather cryptic error message…yeah,
that one took me a while to track down. grrr

Other than that, I prefer spaces … especially if swapping code with
others! :slight_smile:

-Derrick

On Fri, 5 May 2006, malamute jute wrote:

im using vim and i was thinking of changing my preferences on
tabbing/indenting. instead of tabs, it will insert spaces. but i want to
know if there are any implications on using space instead of tabs in the
code. thanks.

The Ruby and Rails folks seem to prefer spaces, with two spaces per
indentation level. The Rails website actually says this is what you
should use if you want to contribute code.

Myself, I prefer tabs, but I suspect I’ll move to what the community
uses
because it isn’t worth struggling with.

I use vim all the time as well, and it’s default bindings with the tabs
and autoindent have been making me insane, and I probably will finally
go
in and shut them off.


Louis Erickson - [email protected] - Lou's Home Page!

Hartley’s Second Law:
Never sleep with anyone crazier than yourself.

So what is the main reason why the rails community uses spaces instead
of
tabs? I’ve always used tabs because it offers control of how much white
space is shown to the current person editing the file, not who
originally
wrote it. My coworker likes to have 8 char wide tabs, I personally hate
that and like to edit with 4 char wide tabs and maybe others like 2.

Rob

Rob M. wrote:

So what is the main reason why the rails community uses spaces instead
of
tabs? I’ve always used tabs because it offers control of how much white
space is shown to the current person editing the file, not who
originally
wrote it. My coworker likes to have 8 char wide tabs, I personally hate
that and like to edit with 4 char wide tabs and maybe others like 2.

Rob

It keeps code looking nice

2 space tabs:

SomeModel.create :value => 1,
:foo => 123,
:bar => ‘asdf’

now convert that to 4 space tabs and you have something like:

SomeModel.create :value => 1,
                                  :foo     => 123,
                                  :bar     => 'asdf'

On May 5, 2006, at 7:10 AM, Louis Erickson wrote:

indentation level. The Rails website actually says this is what you
in and shut them off.


Louis Erickson - [email protected] - Lou's Home Page!

FOr ruby code I always use spaces. It is what most of the ruby code
you will find uses. And a really good reason not to use tabs is that
when you use tabs, you can no longer paster your code into irb to
play with it for testing. Irb will see each tab as a command
completion requests and flip out on you. Since irb is such an
indespensible tool for ruby code, this fact alone warrants only ever
using spaces.

Cheers-
-Ezra