1

I recently updated Vim, and noticed that whenever I open a .txt file, the option tw=78 is set. (Which makes Vim automatically break lines when they would have exceeded 78 characters.) I don't like that, and would like to get rid of it.

I added set tw=0 as the last line in my _vimrc file, but that had no effect. I also looked at the different syntax and filetype files, but there seem to be none for TXT files.

Evgeni Sergeev
  • 1,855
  • 4
  • 23
  • 37

1 Answers1

4

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.

Evgeni Sergeev
  • 1,855
  • 4
  • 23
  • 37
  • 1
    I've just upvoted your answer but thought I should mention that a quick and easy way to find out which file was used to set the `textwidth` (or any) option is to run `:verbose set tw?`. – Anthony Geoghegan Feb 18 '16 at 11:40