以下是我的vimrc
配置。我希望文本在达到textwidth
最大值时被包装到下一行。
syntax on
set tabstop=4
set linebreak
set wrap
filetype indent off
set paste
set tw=120
set ruler
我使用Macbook pro 2014,El Capitan,iterm2。
我也试过set formatoptions+=cqtrol
。
答案 0 :(得分:1)
这是set paste
的效果。来自paste
的Vim帮助:
When the 'paste' option is switched on (also when it was already on):
...
- 'formatoptions' is used like it is empty
formatoptions
的默认值为vt
,其中t
是自动换行所必需的:
t Auto-wrap text using textwidth
请参阅:help fo-table
。
因此,您应该从配置中删除set paste
,或者通过set nopaste
命令暂时取消 。
我建议默认保留nopaste
,即删除set paste
,然后使用pastetoggle
选项。例如,以下命令配置F12
键以切换粘贴模式。
set pastetoggle=<F12>