views:

58

answers:

1

For some reason, in vim whenever there is a line of ruby code with a function including parentheses, eg: string = gets() without a semicolon the next line is indented a level. When there is a semicolon, it works fine. Any ideas as to why this is happening and how to fix it? Also, since it will probably be requested, here is my ~/.vimrc

+1  A: 

You probably don't want set cindent on ruby files.

Use au FileType ruby setlocal nocindent

At the top (before any other au's) for other languages to work properly you need

instead of their respective lines.

mathepic
Just setting the first thing you said worked. Thanks!
Mark Szymanski
@Mark Szymanski - It will break cindent if you try to edit a C file after a Ruby file you need that first line of the last 2.
mathepic
Also, could you accept this?
mathepic
I will, once the time limit is up :P
Mark Szymanski
I just realized that I was confusing `autoindent` with `smartindent`. To be clear `smartindent` might cause some problems with Ruby - if it does, do the same thing I did with `cindent` to `smartindent`.
mathepic
Do not suggest using two different autocommands. Use `setlocal` for doing buffer-local changes. It will eliminate the need of the second autocommand.
ZyX
@Zyx thanks, I'll update my answer (and my `vimrc`!)
mathepic
while we're at it, if you really /do/ want to use `cindent`, `:set cinoptions=+0` should help.
sreservoir