Reputation: 6926
I want to try the following things in vim insert mode:
to have closing bracket/parenthesis inserted (after the cursor) every time I type the opening one
to have #{}
inserted whenever I type #
inside ""
(optionally, inside %()
too)
I know it is possible, but my competence in this part of vim does not even reach the self-starter level.
Upvotes: 2
Views: 109
Reputation: 32926
lh-brackets helps define brackets related mappings. It also provides a few functions aimed at defining context-sensitive mappings and abbreviations (see Map4TheseContext
).
If in ruby %() is associated to a syntax highlighting, Map4TheseContext
will also solve your last request. If not, you'll have to play with searchpair()
to detect the current context. Let me know if you have troubles to come up with a working solution.
Upvotes: 1
Reputation: 66263
This script will do the first one (auto inserting the closing bracket and placing the cursor between the brackets.)
Upvotes: 2