Vim indenteation for ruby

Hey,

I'm not sure anyone else has noticed this, but the vim indentation
for ruby is frustrating. It keeps indenting two spaces instead of
tab. Has anyone else experienced this?

(this happens with cindent turned on. I have no such problem with
 perl or anything else. ideas?)

db
···


“Then we typed the G, and the system crashed”…

found the culprit.
/vim/vim61/ftplugin/ruby.vim
had a line with

" Set shift width to 2, the Ruby standard
setlocal sw=2

I didn’t realize this was a ruby standard… hm

···

On Fri, Aug 02, 2002 at 02:53:18AM +0900, Daniel Bretoi wrote:

Hey,

I’m not sure anyone else has noticed this, but the vim indentation
for ruby is frustrating. It keeps indenting two spaces instead of
tab. Has anyone else experienced this?

(this happens with cindent turned on. I have no such problem with
perl or anything else. ideas?)

db


“Then we typed the G, and the system crashed”…


“Then we typed the G, and the system crashed”…

Daniel Bretoi wrote:

Hey,

I’m not sure anyone else has noticed this, but the vim indentation
for ruby is frustrating. It keeps indenting two spaces instead of
tab. Has anyone else experienced this?

:set ts=2

(and :set noet, but that’s the default, I think)

Makes it so your tabs are two spaces, and it indents by these two-space
tabs automatically.

–Evan, who doesn’t want to begin a tabs-vs-spaces argument

There’s obviously no real standard. That is
someone’s tongue-in-cheek opinion, I assume.

Having said that, I concur with his choice…
the code in The Ruby Way is written pretty
consistently in that manner.

Purely a matter of taste. I recall the humorous
post years ago that was supposed to be the
C source code for the universe. The poster,
who had swiped the code from God, commented
“Note that God uses four-space tabs.” :slight_smile:

Cheers,
Hal

···

----- Original Message -----
From: “Daniel Bretoi” lists@debonair.net
To: “ruby-talk ML” ruby-talk@ruby-lang.org
Sent: Thursday, August 01, 2002 12:57 PM
Subject: Re: vim indenteation for ruby

found the culprit.
/vim/vim61/ftplugin/ruby.vim
had a line with

" Set shift width to 2, the Ruby standard
setlocal sw=2

I didn’t realize this was a ruby standard… hm

Yes, it is; I’d add “set et”.

However…

Why are we setting the sw in an ftplugin?

After all, it says explicitly in ftplugin/README.txt:

“The default filetype plugin files contain settings that 95% of the
users will want to use. They do not contain personal preferences,
like the value of ‘shiftwidth’.”

And…

How do I get my ftplugin/ruby.vim to be distributed with Vim?
Among other things, it makes matchit work with Ruby.

http://vim.sourceforge.net/scripts/script.php?script_id=303

···

On Thursday 01 August 2002 10:57 am, Daniel Bretoi wrote:

/vim/vim61/ftplugin/ruby.vim
had a line with

" Set shift width to 2, the Ruby standard
setlocal sw=2

I didn’t realize this was a ruby standard… hm


Ned Konz
http://bike-nomad.com
GPG key ID: BEEA7EFE

Note the automatic indenting is set by shiftwidth, which is set to 2 in
the filetype plugin, so if you don’t like the ts of 2, you’ll need to
override it there, either by editing ftplugin/ruby.vim, or creating
~/.vim/ftplugin/ruby.vim yourself.

:help ftplugin

···
  • Evan Martin (martine@cs.washington.edu) wrote:

Daniel Bretoi wrote:

I'm not sure anyone else has noticed this, but the vim
indentation for ruby is frustrating. It keeps indenting two
spaces instead of tab. Has anyone else experienced this?

:set ts=2


Thomas ‘Freaky’ Hurst - freaky@aagh.net - http://www.aagh.net/

He was the sort of person whose personality
would be greatly improved by a terminal illness.

Why are we setting the sw in an ftplugin?

There’s no good reason. It should be removed.

After all, it says explicitly in ftplugin/README.txt:

“The default filetype plugin files contain settings that 95% of the
users will want to use. They do not contain personal preferences,
like the value of ‘shiftwidth’.”

And…

How do I get my ftplugin/ruby.vim to be distributed with Vim?
Among other things, it makes matchit work with Ruby.

Contact the current maintainer, I suppose. Failing that, Bram.

If anyone wants to override the sw setting without modifying the “standard”
ruby.vim file, follow these steps:

  1. Edit ~/.vim/ftplugin/ruby.vim
  2. Put your preferences in there

If ~/.vim/ftplugin/ruby.vim already exists, call it “ruby_prefs.vim” or
something instead.

NB. On Windows, s/.vim/vimfiles

Regards,
Gavin

···

From: “Ned Konz” ned@bike-nomad.com

> > Purely a matter of taste. I recall the humorous > post years ago that was supposed to be the > C source code for the universe. The poster, > who had swiped the code from God, commented > "Note that God uses four-space tabs." :) > Yes, that's true. I received the same revelation.
···

On Thursday 01 August 2002 01:09 pm, Hal E. Fulton wrote:

I don’t mind tab being represented by two spaces, I prefer 3, but sw
actually MAKES an indentation of 2 spaces vs a real tab. That, I do NOT
like. I think keeping tabs instead of spaces allows anyone to set their
tab/space preference. Spaces are much more imposing.

db

···

On Sat, Aug 03, 2002 at 12:10:50AM +0900, Thomas Hurst wrote:

  • Evan Martin (martine@cs.washington.edu) wrote:

Daniel Bretoi wrote:

I'm not sure anyone else has noticed this, but the vim
indentation for ruby is frustrating. It keeps indenting two
spaces instead of tab. Has anyone else experienced this?

:set ts=2

Note the automatic indenting is set by shiftwidth, which is set to 2 in
the filetype plugin, so if you don’t like the ts of 2, you’ll need to
override it there, either by editing ftplugin/ruby.vim, or creating
~/.vim/ftplugin/ruby.vim yourself.

:help ftplugin


Thomas ‘Freaky’ Hurst - freaky@aagh.net - http://www.aagh.net/

He was the sort of person whose personality
would be greatly improved by a terminal illness.


“Then we typed the G, and the system crashed”…

While we’re on the subject, comments shouldn’t be forcibly continued when
pressing ENTER, o, etc.

···

From: “Ned Konz” ned@bike-nomad.com

Why are we setting the sw in an ftplugin?

There’s no good reason. It should be removed.

:set formatoptions-=ro

···

On Fri, Aug 02, 2002 at 04:51:54AM +0900, Gavin Sinclair wrote:

While we’re on the subject, comments shouldn’t be forcibly continued when
pressing ENTER, o, etc.


moved

Oh God! can I not save
One from the pitiless wave?
(Poe)

Oh, I realise that, but it shouldn’t be in the standard ftplugin.

:set formatoptions-=ro

···

----- Original Message -----
From: “Kyle Rawlins” rawlins@cs.umass.edu

On Fri, Aug 02, 2002 at 04:51:54AM +0900, Gavin Sinclair wrote:

While we’re on the subject, comments shouldn’t be forcibly continued when
pressing ENTER, o, etc.