Vim 在开头添加文本时不换行
Vim not breaking line when adding text at the beginning
我将 textwidth=20
设置为 Vim 自动换行并且效果很好,如下所示:
1
1234 1234 1234 1234
2
1234 1234 1234 1234
3
1234 1234 1234 1234
但是,当我转到第 2 行的开头并添加一些文本时,该行没有中断,如下所示:
1
1234 1234 1234 1234
2
1234 1234 1234 1234 1234 1234 1234 1234
3
1234 1234 1234 1234
然后我必须使用 gqap
来修正给出的宽度:
1
1234 1234 1234 1234
2
1234 1234 1234 1234
3
1234 1234 1234 1234
4
1234 1234 1234 1234
有没有办法在行首添加文本时自动换行?
您要找的是auto-format
。参见 :h auto-format
:set formatoptions+=a
When the 'a' flag is present in 'formatoptions' text is formatted
automatically when inserting text or deleting text.
我将 textwidth=20
设置为 Vim 自动换行并且效果很好,如下所示:
1
1234 1234 1234 1234
2
1234 1234 1234 1234
3
1234 1234 1234 1234
但是,当我转到第 2 行的开头并添加一些文本时,该行没有中断,如下所示:
1
1234 1234 1234 1234
2
1234 1234 1234 1234 1234 1234 1234 1234
3
1234 1234 1234 1234
然后我必须使用 gqap
来修正给出的宽度:
1
1234 1234 1234 1234
2
1234 1234 1234 1234
3
1234 1234 1234 1234
4
1234 1234 1234 1234
有没有办法在行首添加文本时自动换行?
您要找的是auto-format
。参见 :h auto-format
:set formatoptions+=a
When the 'a' flag is present in 'formatoptions' text is formatted automatically when inserting text or deleting text.