Make vim stop splitting my Git commit messages

Naf*_*Kay 16 vim git

Vim has this awful annoying habit of splitting my commit messages and automatically line-breaking them, rendering the second line with a red background for some reason.

在此处输入图片说明

How can I make vim stop doing this?

Ing*_*kat 6

文件类型插件强制执行首选的 Git 提交消息样式:短标题和硬换行符。如果您不同意该样式,请通过将以下内容放入来撤消设置~/.vim/after/ftplugin/gitcommit.vim

setlocal wrap formatoptions<
Run Code Online (Sandbox Code Playgroud)

  • 对于那些想知道“formatoptions&lt;”如何成为“setlocal”的有效参数的人,[`:setlocal`](https://vimhelp.appspot.com/options.txt.html#:setlocal) 的文档解释说它将“通过复制值将 {option} 的本地值设置为其全局值。” 因此,此命令将删除插件添加的 `t` 和 `l` 标志(记录在 [`fo-table`](https://vimhelp.appspot.com/change.txt.html#fo-table) 中)到 [`'formatoptions'`](https://vimhelp.appspot.com/options.txt.html#%27formatoptions%27)。 (2认同)

小智 5

我发现我需要的设置~/.vim/after/ftplugin/gitcommit.vim是:

setlocal textwidth=0