Forum: Ruby Vim two space indentation

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
508861510639b56d61eb30e6a28b01d9?d=identicon&s=25 John Maclean (Guest)
on 2006-01-05 13:24
(Received via mailing list)
Hi guys,

This has probably been done before but I've looked through 5000+ emails
and I've not seen a simple solution. I'd like to have two space
indentation for *.rb files or those whose first line begins with
!#/usr/bin/ruby. At the moment vim gives me eight spaces, (or is it a
tab?).

I have the following lines in ~./vimrc

set nocompatible
syntax on
filetype plugin indent on
filetype indent on    " Enable filetype-specific indenting
filetype on           " Enable filetype detection

I also have the following files;
/usr/share/vim/vim63/ftplugin/ruby.vim
/usr/share/vim/vim63/compiler/ruby.vim
/usr/share/vim/vim63/indent/ruby.vim
/usr/share/vim/vim63/syntax/ruby.vim

--

John Maclean
MSc (DIC)
07739 171 531
Bf6862e2a409078e13a3979c00bba1d6?d=identicon&s=25 Gregory Seidman (Guest)
on 2006-01-05 13:33
(Received via mailing list)
On Thu, Jan 05, 2006 at 09:23:23PM +0900, John Maclean wrote:
} Hi guys,
}
} This has probably been done before but I've looked through 5000+
emails and I've not seen a simple solution. I'd like to have two space
indentation for *.rb files or those whose first line begins with
!#/usr/bin/ruby. At the moment vim gives me eight spaces, (or is it a
tab?).
}
} I have the following lines in ~./vimrc
}
} set nocompatible
} syntax on
} filetype plugin indent on
} filetype indent on    " Enable filetype-specific indenting
} filetype on           " Enable filetype detection
}
} I also have the following files;
} /usr/share/vim/vim63/ftplugin/ruby.vim
} /usr/share/vim/vim63/compiler/ruby.vim
} /usr/share/vim/vim63/indent/ruby.vim
} /usr/share/vim/vim63/syntax/ruby.vim

I came to vim before the days of ftplugin. Actually, I came to vi first,
and already had filetype-specific configurations set up, so I sort of
ported that to vim when it came along. That said, the config lines you
want
are:

set ts=2 sw=2 expandtab

It looks to me like you want it in either the ftplugin or indent
directory,
but I'm not sure which. I believe the indent directory is intended for
automatic indentation configuration (equivalent to cindent), but again I
am
not sure.

} John Maclean
--Greg
82e62c756d89bc6fa0a0a2d7f2b1e617?d=identicon&s=25 Ross Bamford (Guest)
on 2006-01-05 17:44
(Received via mailing list)
On Thu, 05 Jan 2006 12:31:09 -0000, Gregory Seidman
<gsslist+ruby@anthropohedron.net> wrote:

> }
> } /usr/share/vim/vim63/syntax/ruby.vim
> directory,
> but I'm not sure which. I believe the indent directory is intended for
> automatic indentation configuration (equivalent to cindent), but again I
> am
> not sure.
>
> } John Maclean
> --Greg
>

I just have it in ~/.vimrc, as follows:

	set nocompatible
	syntax on
	filetype plugin indent on
	set tabstop=2
	set shiftwidth=2
	set expandtab
508861510639b56d61eb30e6a28b01d9?d=identicon&s=25 John Maclean (Guest)
on 2006-01-05 17:44
(Received via mailing list)
Thanks!

I put the folowing line:-
set ts=2 sw=2 expandtab
into /usr/share/vim/vim63/indent/ruby.vim and it works

On Thu, 5 Jan 2006 21:31:09 +0900
92324d1a212698587be6a5f349c7a9b4?d=identicon&s=25 Oliver Andrich (oandrich)
on 2006-01-05 17:44
(Received via mailing list)
Hi,

I use a setting like that in my .vimrc file.

if has("autocmd")

  augroup ruby
    au BufReadPre,FileReadPre set kp=ri sw=2 ts=2 expandtab
  augroup END

endif

With some more settings for Python, Perl and so on. And I would also
suggest to active autoindent and smartindent. :)

Best regards,
Oliver
Bfcc9047bea80035a936648dc1912ec4?d=identicon&s=25 Gavin Sinclair (Guest)
on 2006-01-06 09:10
(Received via mailing list)
John Maclean wrote:
> Hi guys,
>
> This has probably been done before but I've looked through 5000+ emails and I've not 
seen a simple solution. I'd like to have two space indentation for *.rb files or those 
whose first line begins with !#/usr/bin/ruby. At the moment vim gives me eight spaces, (or 
is it a tab?).
> [...]

The best answer is to create a file ~/.vim/ftplugin/ruby.vim with the
following

  set ts=2 sw=2 sts=2 et

Regards,
Gavin
5d8990b757a1305f8e9100e9e4e5073d?d=identicon&s=25 WATANABE Hirofumi (Guest)
on 2006-01-06 09:22
(Received via mailing list)
Hi,

"Gavin Sinclair" <gsinclair@gmail.com> writes:

> John Maclean wrote:
> > Hi guys,
> >
> > This has probably been done before but I've looked through 5000+ emails and I've not 
seen a simple solution. I'd like to have two space indentation for *.rb files or those 
whose first line begins with !#/usr/bin/ruby. At the moment vim gives me eight spaces, (or 
is it a tab?).
> > [...]
>
> The best answer is to create a file ~/.vim/ftplugin/ruby.vim with the
> following
>
>   set ts=2 sw=2 sts=2 et

In this case, it might be better to use setlocal instead of set.
This topic is locked and can not be replied to.