Emacs 中是否有类似于 Surround.vim 的扩展或模式?
Surround.vim 是一个漂亮的 vim 扩展,可以让你围绕块带有 、方括号、大括号和几乎任何任意“环绕”字符的文本。它支持段落和文字环绕,但我经常在视觉模式下使用它。 我正在玩 Emacs,想知道是否有类似的东西;可以让我突出显示一个区域,然后将标记的区域(或矩形)用大括号、方括号或标签括起来。
Surround.vim is a nifty vim extension that allows you to surround blocks of text with , brackets, braces, and pretty much any arbitrary "surround" character. It supports paragraph and word surround, but I frequently use it in visual mode.
I'm playing around with Emacs and wondering if there's something similar; something that will let me highlight a region and then have the marked region (or rectangle) enclosed with braces, brackets or tags.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
也许 wrap-region 就是您所需要的。
如果需要用分隔符、标签等包装某些内容,smartparens 是另一个绝佳的选择。
Maybe wrap-region is what you need.
smartparens is another excellent option if need to wrap something with delimiters, tags, etc.
我使用 evil-surround。它模拟 vim 行为,但不幸的是可能不是大多数 emacs 用户想要的,因为它需要 evil vim 模式。
然而,它可能适合你,也可能不适合你,因为你首先引用了 around.vim。
evil-surround 似乎支持 Surround.vim 中的大部分功能,包括修改环境。
I use evil-surround. It emulates vim behaviour but unfortunately might not be what most emacs users want since it requires the evil vim mode.
However, it may or may not be right for you since you referenced surround.vim in the first place.
evil-surround seems to support most of the features in Surround.vim, including modifying surroundings.
我认为标签没有内置任何内容,但对于括号,您可以执行 M-(。对于括号/大括号/引号,您可以执行以下操作:
请注意,如果您没有区域突出显示,它只会插入一对任意内容并将光标放在它们之间。也可以方便地删除匹配的任意内容
如果你想插入标签对,这是一些简单的 elisp:
I don't think there is anything built in for tags, but for parens you can do M-(. For brackets/braces/quotes you could do:
Note that if you don't have a region highlighted, it will just insert the pair of whatevers and put the cursor in between them. Also handy for deleting matching whatevers is
If you want to insert tag pairs, it's some simple elisp:
不知道在 Emacs 中有什么方法可以做到这一点,甚至不知道使用模块。
我的 Elisp 有点生疏,这里有一个简单的函数,它将用引号 (") 将当前区域(标记的文本)或单词括起来:
Don't know of any way of doing that in Emacs, not even with a module.
My Elisp is a little rusty, buy here's a simple function that will enclose the current region (marked text) or word with quotes ("):
是的,从 1 周前开始,有 Surround.vim 的克隆版: http://github .com/timcharper/vimpulse-surround.el
它需要 vimpulse,而 vimpulse 需要 vim。它实现了 around.vim 的大部分功能。
Yes, there is a clone of surround.vim, as of 1 week ago: http://github.com/timcharper/vimpulse-surround.el
It requires vimpulse, which requires vim. It implements much of surround.vim's functionality.
也许 evil-surround 就是您正在寻找的。
谢谢。
maybe evil-surround is what you are looking for.
thanks.
所以你想选择一个区域或类似的区域,然后在它周围制作一个框,就像各种评论模式一样?我相信 emacs-wiki (http://www.emacswiki.org/) 有一些 ascii 行艺术(还有一个 Figlet 工具)就可以做到这一点。寻找盒子、相当、线条艺术......
So you want to select a region or similar and then make a box around it like a various modes do for comments? I believe emacs-wiki (http://www.emacswiki.org/) has some ascii-line art (and a figlet tool as well) that will do that. Searching for box, quite, line art ...