I'd like to start using vimscript to automate some more complicated parts of my workflow. I'm looking for a concrete advanced example to get me started. How would you vim guru's implement the following?
I'm in an empty buffer for a file located at lib/foo/bar/buz.rb
. I want to use my file context + a binding to insert the following into the buffer:
module Foo
module Bar
class Buz
end
end
end
What's the vim function look like?
Bonus: Vim function to update class definition to reflect current location
I think this example will take my vim scripting to the next level. Thanks!
This is ultimately what I came up with.
The above snippet assumes you have tpope's vim-abolish plugin installed. This helps with the transformation of snakecase file paths into mixedcase object names.
Sourcing the above and calling
:GenerateRubyClassDefinition()
from an open file buffer will echo the target output.