V
Vincent Foley
Hi to all the vim users,
I have always used Vim to edit my Ruby code, and I've always been very
grateful that Ruby had both indenting and syntax files. However, the
indenting has started to irritate me lately. It doesn't always indent
the way it should.
In Emacs, when you want to write method(foo, bar, baz) with foo, bar
and baz on separate lines, bar and baz will align themselves with foo.
method(foo,
bar,
baz)
However, with vim, bar will align itself with method not with foo, and
baz will align itself with bar. So you end up with:
method(foo,
bar,
baz)
And you have to manually align the parameters. It's annyoing,
especially if you then decide to reindent the whole file with =G, then
you just ruin the alignment you made and you either need to do it again
or put up with bad style.
Similar bad indenting happens with multiple-lines arrays, hashes,
assignements to the result of an expression such as if or case[1], and
probably other case I'm not thinking of right now.
Does anyone have experience in vim indent files hacking who could maybe
fix those issues, or point me to a good reference on how to fix this?
This is starting to seriously annoy me.
Vincent.
[1]
foo = case bar
when 1: 2
when 2: 3
end
instead of
foo = case bar
when 1: 2
when 2: 3
end
I have always used Vim to edit my Ruby code, and I've always been very
grateful that Ruby had both indenting and syntax files. However, the
indenting has started to irritate me lately. It doesn't always indent
the way it should.
In Emacs, when you want to write method(foo, bar, baz) with foo, bar
and baz on separate lines, bar and baz will align themselves with foo.
method(foo,
bar,
baz)
However, with vim, bar will align itself with method not with foo, and
baz will align itself with bar. So you end up with:
method(foo,
bar,
baz)
And you have to manually align the parameters. It's annyoing,
especially if you then decide to reindent the whole file with =G, then
you just ruin the alignment you made and you either need to do it again
or put up with bad style.
Similar bad indenting happens with multiple-lines arrays, hashes,
assignements to the result of an expression such as if or case[1], and
probably other case I'm not thinking of right now.
Does anyone have experience in vim indent files hacking who could maybe
fix those issues, or point me to a good reference on how to fix this?
This is starting to seriously annoy me.
Vincent.
[1]
foo = case bar
when 1: 2
when 2: 3
end
instead of
foo = case bar
when 1: 2
when 2: 3
end