OT: Vim/Ruby Configuration Files

I love Vim. My workplace uses 3 spaces for indenting its C/C++, but I
like to use 2 for ruby files. Any tips on how to accomplish that?

-Ben

···

On 10/5/05, Doug Kearns <dougkearns@gmail.com> wrote:

G'day folks,

A new release of Vim/Ruby has just been uploaded to RubyForge.

This includes a few minor bug fixes and is intended as the final release
prior to next week's Vim 6.4 beta.

If there are any serious problems please report them, as soon as
possible, via the project's bug tracker so they can be attended to prior
to the Vim beta release.

Regards,
Doug (for the Vim-Ruby Team)

http://vim-ruby.rubyforge.org/
http://rubyforge.org/projects/vim-ruby/

Hi,

Ben wrote:

I love Vim. My workplace uses 3 spaces for indenting its C/C++, but I
like to use 2 for ruby files. Any tips on how to accomplish that?

Try this:

au BufRead,BufNewFile *.rb set sw=2,ts=2

Of course you can add any number of other settings (and it works for other
sorts of globs too. Oh, and did I mention that vim rocks? ;)).

···

--
# Best regards, Jan 'jast' Krueger <jast at ruby-co de>
print'text: ';l=gets;I=['%q,0-9a-f,',',','%q,(-/:-@[,'];i="pack"+
"('H*')";l=eval("l.un#{i}[0].tr #{I}"); $><<"$><<[%q_#{l.gsub /(^
\W{64}|\W{72})/x,"\\1\n"}_.\ngsub(/\\s/,'').tr(#{I.reverse})]."+i

Ben wrote:

I love Vim. My workplace uses 3 spaces for indenting its C/C++, but I
like to use 2 for ruby files. Any tips on how to accomplish that?

(3 spaces is seriously the most retarded indentation-level ever, hands
down...sorry, just had to get that off my chest.)

Add

filetype plugin on

to your ~/.vimrc

Then create the file ~/.vim/ftplugin/ruby.vim and add the following in
it:

set shiftwidth=2

and perhaps

set softtabstop=2

if you like "tabs" to be "transparent". (It’s really nice.),
        nikolai

···

--
Nikolai Weibull: now available free of charge at http://bitwi.se/\!
Born in Chicago, IL USA; currently residing in Gothenburg, Sweden.
main(){printf(&linux["\021%six\012\0"],(linux)["have"]+"fun"-97);}

If you put the changes in $HOME/.vim/after/ftplugin/ruby.vim, then they'll
run after--and override--whatever is in the system wide ftplugin/ruby.vim.

Just use setlocal instead of set.

···

On 10/5/05, Nikolai Weibull <mailing-lists.ruby-talk@rawuncut.elitemail.org> wrote:

Then create the file ~/.vim/ftplugin/ruby.vim and add the following in
it:

It is really quite awful. The only thing I can think is that they
couldn't get the 2-spacers to agree with the 4-spacers, so they split
the difference.

  Thanks for the tips.

-Ben

···

On 10/5/05, Nikolai Weibull <mailing-lists.ruby-talk@rawuncut.elitemail.org> wrote:

(3 spaces is seriously the most retarded indentation-level ever, hands
down...sorry, just had to get that off my chest.)

Jan 'jast' Krueger wrote:
> au BufRead,BufNewFile *.rb set sw=2,ts=2

Fantastic, been wondering how to do that for a while.
I needed to replace the 2nd comma with a space to avoid an
error message. I also use "sts" instead of "ts", so that
programs expecting 8-space tabs still do the right thing.

Clifford Heath.

Nikolai Weibull wrote:

Then create the file ~/.vim/ftplugin/ruby.vim and add the following in
it:

set shiftwidth=2 [etc.]

I prefer the file ~/.vim/ftplugin/ruby_personal.vim.

It'll still be read for Ruby programs; it's a self-describing filename;
and, most importantly, it won't be overwritten by some over-zealous
Vim/Ruby configuration file distribution!

Gavin

Louis J Scoras wrote:

> Then create the file ~/.vim/ftplugin/ruby.vim and add the following
> in it:

If you put the changes in $HOME/.vim/after/ftplugin/ruby.vim, then
they'll run after--and override--whatever is in the system wide
ftplugin/ruby.vim.

Yes, but there's sort of a praxis of not including stuff like
'shiftwidth' or 'softtabstop' in the global ftplugins, so that's not an
issue here.

Just use setlocal instead of set.

Yes, that was certainly a mistake (well, a mental typo really). Always
use setlocal in ftplugins,
        nikolai

···

On 10/5/05, Nikolai Weibull > <mailing-lists.ruby-talk@rawuncut.elitemail.org> wrote:

--
Nikolai Weibull: now available free of charge at http://bitwi.se/\!
Born in Chicago, IL USA; currently residing in Gothenburg, Sweden.
main(){printf(&linux["\021%six\012\0"],(linux)["have"]+"fun"-97);}

Ben wrote:

···

On 10/5/05, Nikolai Weibull > <mailing-lists.ruby-talk@rawuncut.elitemail.org> wrote:

> (3 spaces is seriously the most retarded indentation-level ever,
> hands down...sorry, just had to get that off my chest.)

  It is really quite awful. The only thing I can think is that they
  couldn't get the 2-spacers to agree with the 4-spacers, so they
  split the difference.

Precisely, ;-),
        nikolai

--
Nikolai Weibull: now available free of charge at http://bitwi.se/\!
Born in Chicago, IL USA; currently residing in Gothenburg, Sweden.
main(){printf(&linux["\021%six\012\0"],(linux)["have"]+"fun"-97);}

Gavin Sinclair wrote:

Nikolai Weibull wrote:

> Then create the file ~/.vim/ftplugin/ruby.vim and add the following
> in it:
>
> set shiftwidth=2 [etc.]

I prefer the file ~/.vim/ftplugin/ruby_personal.vim.

True, that’s a possible alternative (although having it in ~/ kind of
gives it the air of being personal either way).

It'll still be read for Ruby programs; it's a self-describing
filename; and, most importantly, it won't be overwritten by some
over-zealous Vim/Ruby configuration file distribution!

:-D,
        nikolai

···

--
Nikolai Weibull: now available free of charge at http://bitwi.se/\!
Born in Chicago, IL USA; currently residing in Gothenburg, Sweden.
main(){printf(&linux["\021%six\012\0"],(linux)["have"]+"fun"-97);}