是否有相当于 Linux/Unix “fold” 的 Vim? 命令?
我意识到 Vim 中有一种隐藏/折叠行的方法,但我正在寻找一种选择文本块并让 Vim 在第 80 列或附近换行的方法。
大多数情况下我想在注释中使用它我在现有评论中添加了一些文本,使其超过 80 个字符。 如果它也可以在换行时在行首插入注释标记,那就太好了。 另外,我更喜欢不自动换行整个文件的解决方案,因为在将结构化代码保持在 80 个字符行长度以下时,我使用了一个特定的约定。
这主要针对 Python 代码,但我也有兴趣学习该问题的一般解决方案,以防我必须将其应用于其他类型的文本。
I realize there's a way in Vim to hide/fold lines, but what I'm looking for is a way to select a block of text and have Vim wrap lines at or near column 80.
Mostly I want to use this on comments in situations where I'm adding some text to an existing comment that pushes it over 80 characters. It would also be nice if it could insert the comment marker at the beginning of the line when it wraps too. Also I'd prefer the solution to not autowrap the entire file since I have a particular convention that I use when it comes to keeping my structured code under the 80 character line-length.
This is mostly for Python code, but I'm also interested in learning the general solution to the problem in case I have to apply it to other types of text.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
它由 textwidth 选项控制,请参阅
":help gq"
了解更多信息。默认情况下,
gq
将在当前行上工作,但您可以使用 Ctrl+V 突出显示可视块,并设置多行/段落的格式。gqap
执行文本的当前“段落”。It's controlled by the textwidth option, see
":help gq"
for more info.gq
will work on the current line by default, but you can highlight a visual block with Ctrl+V and format multiple lines / paragraphs like that.gqap
does the current "paragraph" of text.看一下“:help =”和“:help 'equalprg”
,在正常模式下==通过外部折叠程序过滤当前行。 或者视觉选择某些内容并点击=
Take a look at ":help =" and ":help 'equalprg"
and in normal mode == filters the current line through the external fold program. Or visual-select something and hit =