vim 中长段落的方便自动换行
Convenient word wrapping for long paragraphs in vim
我正在寻找一种在 vim 中编写和编辑较长段落的技巧。
本质上,我想要的是 vim 表现得像我目前正在写这个问题的 html 文本区域。
在某种程度上,如果我 set wrap
和 set linebreak
,j
映射到 gj
,k
映射到 [=16,我会得到这种行为=].但是,在视觉模式下,移动仍然是逐行的,我知道没有方便的方法来选择长行的一部分。
此外,我知道 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 表现得像我目前正在写这个问题的 html 文本区域。
在某种程度上,如果我 set wrap
和 set linebreak
,j
映射到 gj
,k
映射到 [=16,我会得到这种行为=].但是,在视觉模式下,移动仍然是逐行的,我知道没有方便的方法来选择长行的一部分。
此外,我知道 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.
...