Does anyone have a plugin or macro to replace matching {
braces }
with do
and end
in Vim? Preferably turning a single-line statement like this:
foo.each { |f| f.whatever }
into:
foo.each do |f|
f.whatever
end
I could make a macro myself for that one case, but I'd like something that could also handle converting existing multi-line, potentially complicated blocks, like:
foo.each { |f|
f.bars.each { |b| b.whatever }
hash = { a: 123, b: 456 }
}
into:
foo.each do |f|
f.bars.each { |b| b.whatever }
hash = { a: 123, b: 456 }
end
I've looked at vim-surround and rails.vim, and haven't found a way with either.
{,}
was replaced, the innerf.bars.each{...
not? – Purgatory