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
views:
58answers:
1
+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
2010-10-17 23:29:24
Just setting the first thing you said worked. Thanks!
Mark Szymanski
2010-10-17 23:31:06
@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
2010-10-17 23:31:58
Also, could you accept this?
mathepic
2010-10-17 23:32:24
I will, once the time limit is up :P
Mark Szymanski
2010-10-17 23:33:09
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
2010-10-17 23:34:39
Do not suggest using two different autocommands. Use `setlocal` for doing buffer-local changes. It will eliminate the need of the second autocommand.
ZyX
2010-10-18 07:43:53
@Zyx thanks, I'll update my answer (and my `vimrc`!)
mathepic
2010-10-18 23:40:26
while we're at it, if you really /do/ want to use `cindent`, `:set cinoptions=+0` should help.
sreservoir
2010-10-18 23:44:43