开发者

few vim autoinserts for ruby needed

开发者 https://www.devze.com 2023-01-16 08:22 出处:网络
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

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 i开发者_开发技巧s possible, but my competence in this part of vim does not even reach the self-starter level.


This script will do the first one (auto inserting the closing bracket and placing the cursor between the brackets.)


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消