保持括号平衡(Vim 的 Paredit?)
Emacs 有 Paredit ,它可以主动防止您输入不平衡的括号(缺少 CQ (
强制插入一个字面括号,或者其他疯狂的操作)。插入一个左括号也会插入一个右括号,或者同时删除左括号和右括号,或者两者都不删除。新括号中的裸字、从当前封闭的括号中踢出一个单词、扩展括号以吸收更多附近的单词等等,
。
imap ( ()<Left>
但是模仿其他一些更强大的功能的最佳方法是什么 Vim 中 Paredit 的功能?
Emacs has Paredit which actively prevents you from typing unbalanced parentheses (short of C-Q (
to force-insert a literal one, or other craziness). Inserting an open paren also inserts a closing one. Backspacing over a paren either deletes both the opening and closing paren, or neither. There are shortcuts to wrap a bare word in new parens, kick a word out of currently enclosing parens, expand parens to slurp up more nearby words, and so on.
Something like
imap ( ()<Left>
can get you started in Vim. But what's the best way to emulate some of the other more powerful features of Paredit in Vim?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Tamas Kovacs 创建了一个类似于 Emacs 版本的 Vim paredit 脚本。
Tamas Kovacs has created a Vim paredit script similar to the Emacs version.
我可以推荐一下我的包围系统吗?
注意:更喜欢直接从 svn 存储库获取它,新版本更容易满足我们的需求。
如果您对详细信息/do-it-yourself-way感兴趣,请查看 相关提示vim.wikia。
May I suggest my bracketing system?
NB: prefer to fetch it directly from the svn repository, the new version is much more easier to tune to our needs.
If you are interested in the details/do-it-yourself-way, have a look at the related tip on vim.wikia.