vim - vim 中长段落方便的自动换行

标签 vim formatting word-wrap

我正在寻找一种在 vim 中编写和编辑较长段落的技术。
本质上,我想要的是 vim 表现得像我目前正在写这个问题的 html textarea。

如果我 set wrap 在某种程度上我会得到这种行为和 set linebreak , 与 j映射到 gjk映射到 gk .然而,在视觉模式下,移动仍然是线状的,我知道没有方便的方法来选择长线的一部分。

此外,我知道 textwidth如果光标的当前列高于某个阈值,则选项会自动换行。
但是,如果我从中间编辑该行,当它变得太长时,该行不会自动断开。

我也知道我可以使用 gq格式化一组选定的行,但一段时间后它会变得很烦人。

在 vim 中自动换行的技术是什么?

最佳答案

如果您设置 a在您的格式选项中,您可能会得到您想要的:

:set formatoptions+=a
见:http://vimdoc.sourceforge.net/htmldoc/change.html#auto-format
...
a   Automatic formatting of paragraphs.  Every time text is inserted or
    deleted the paragraph will be reformatted.  See |auto-format|.
    When the 'c' flag is present this only happens for recognized
    comments.
...

关于vim - vim 中长段落方便的自动换行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33122946/

相关文章:

vim - 执行 :nohlsearch on InsertEnter

Javascript:使用 toLocaleString + Tofixed

c - C中孤花括号代码块的含义

html - CSS:格式化布局的最佳方式

java - 使用复选框在文本区域包装文本

android - Android 中的 Textview 换行

html - 文本行转到新行,而不是换行,即使使用自动换行 :break-word

vim - 跳转 git diff

bash - vim 终端 OS X Mountain Lion 中的光标颜色

vim - vim 中术语 "buffer"和 "window"的含义是什么?