aidan
aidan

Reputation: 1785

customize vim with ruby scripts

Vimscript is difficult. Ruby is not quite so diffiuclt. Customizing Vim with Ruby scripts can be done, and I am trying to learn how. This is a useful presentation about it which covers the basics, but meaningful examples are scarce (and these are rather complicated), so I'm wondering if anyone with experience in this area can offer some smaller examples of Vim mappings and shortcuts written in Ruby.

As a specific example of the kind of scale I'm looking for, let's suppose I want to create section headers for my documentation or something, as in

----------------------------------------------
------------------- SECTION ------------------
----------------------------------------------  

where the section name is centered in the set of hyphens, and to achieve this I visually select the word

SECTION

on it's own line, and hit leader <arbitrary keystroke>.

Upvotes: 0

Views: 63

Answers (1)

Ingo Karkat
Ingo Karkat

Reputation: 172580

Counterargument: Vimscript isn't difficult, maybe a bit different; after all, much of it is modeled after Python.

I do agree that for certain, complex tasks (especially anything that requires interaction with the "outside world", be it file systems, web service calls, etc.), or stuff that benefits from library functions, a different programming language (and fortunately one can choose among powerhorses like Perl, Python, and Ruby) has undeniable benefits.

But the example task you're giving is just a simple sequence of yanking, simple string manipulation, followed by paste. There's little meat, and the interaction with the Vim buffer isn't that different when done in an integration language. That's my main point: You still have to integrate with Vim, and for that, some knowledge of Vim's structure (and that means Vimscript) is necessary.

Upvotes: 1

Related Questions