Остановить Vim от автоматического tw = 78 переноса текстовых файлов с переносом строки

799
Evgeni Sergeev

Я недавно обновил Vim и заметил, что когда я открываю .txtфайл, опция tw=78устанавливается. (В результате Vim автоматически разбивает строки, если их длина превышает 78 символов.) Мне это не нравится, и я хотел бы от него избавиться.

Я добавил set tw=0в качестве последней строки в моем _vimrcфайле, но это не имело никакого эффекта. Я также рассмотрел различные файлы синтаксиса и типов файлов, но, похоже, их нет для файлов TXT.

1

1 ответ на вопрос

3
Evgeni Sergeev

I found the solution on this thread. It turned out that since 2011, vimrc_example.vim was updated to include this textwidth=78 rule as an autocommand, and my _vimrc sources vimrc_example.vim (probably because I based it on the original — which means this situation will apply for many users).

One solution is to find the line in your .vimrc, that says

source $VIMRUNTIME/vimrc_example.vim 

And after that line, insert the following line to unset the particular autocommand that's making a nuisance:

au! vimrcEx FileType text 

How I found the solution: I suspected that it was an autocommand, so I tried looking through all autocommands by using the :autocmd command. But there were just too many. To simplify things, I inserted that output into a spare buffer, as described here. Searching for tw=78 showed the culprit autocommand with the keyword vimrcEx, and then asking Google for the keyword (or I could have grepped Vim's directory) lead us to the solution.

Я только что проголосовал за ваш ответ, но подумал, что должен упомянуть, что быстрый и простой способ выяснить, какой файл использовался для установки опции `textwidth '(или любой другой), это запустить`: verbose set tw? `. Anthony Geoghegan 8 лет назад 1