Vim 魔术结束括号
如果我可以在 vim 中输入 ]
(或其他一些字符,可能是
)并让它自动插入正确关闭的括号,那就太好了开口支架。例如。如果我的缓冲区中有这个:
object(function(x) { x+[1,2,3
然后我按 ]]]
,字符 ]})
将被插入。一个人怎样才能做到这一点呢?
It would be great in vim if I could type ]
(or some other character, maybe <C-]>
) and have it automatically insert whichever bracket properly closes the opening bracket. Eg. if I have this in my buffer:
object(function(x) { x+[1,2,3
And I press ]]]
, the characters ]})
would be inserted. How might one accomplish this this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这是您可能想要的草图。内置函数
searchpair
和searchpairpos
对于各种文本编辑任务有很大帮助:)要舒适地使用它,请为其制作一个
imap
:< strong>编辑:过度转义搜索正则表达式,因此
\
包含在搜索中。现在少了一个问题。Here's a sketch of what you probably wanted. The builtin functions
searchpair
andsearchpairpos
are of enormous help for various text editing tasks :)To use it comfortably, make an
imap
of it:Edit: over-escaped the search regexp so
\
got included in the search. One less problem now.结合autoclose插件,可以设置:
Autoclose会插入匹配的括号,然后ctrl-L将跳过它而不离开插入模式。 Ctrl-L 对我来说比 ctrl-] 更有意义。
这是我能达到的最接近我所说的你所要求的:“让我每次都按相同的键来跳过输入正确的括号,无论该括号是什么”。我不会对此进行 imap ] (不带修饰符),但如果您想尝试一下,没有什么可以阻止您。
Combined with the autoclose plugin, you can set:
Autoclose will insert the matching bracket, then ctrl-L will skip over it without leaving insert mode. Ctrl-L makes more sense to me than ctrl-].
This is as close as I can get to what I'd say you're asking for: "let me just press the same key every time to skip entering the correct bracket, no matter what that bracket is". I'd not imap ] (without modifier) to this, but there's nothing stopping you if you want to try it out.
你可以将其添加到你的 .vimrc 中,它会自动关闭括号
You can add that to your .vimrc and it will autoclose brackets