RunHolt
RunHolt

Reputation: 1972

how to prevent textwidth from reseting on txt files

Whenever I open txt files (and some others) I get my textwidth set to 80. I think this is coming from syntax or ftplugin. I'd like to fix this in my _vimrc so I don't have to call "set tw=0" every time I open a file that has this setting.

Upvotes: 2

Views: 451

Answers (3)

Mark Leighton Fisher
Mark Leighton Fisher

Reputation: 5693

/etc/vimrc can also contain a set tw command - it certainly did in my case, thereby forcing all my files to a text width of 78 until I changed it manually.

Upvotes: 0

RunHolt
RunHolt

Reputation: 1972

The problem was in vimrc_example.vim the line

autocmd FileType text setlocal textwidth=78

sets the textwidth on txt files. Also my formatoptions get reset and no longer have l or lv (verbose doesn't give any detail who did it)

Upvotes: 3

benjifisher
benjifisher

Reputation: 5112

My guess is that you are getting the defaults, not a setting from an ftplugin. Check

:verbose set tw? ft?

to confirm. See the examples under

:help autocmd-patterns

for one way to set your own defaults for *.txt files.

On second thought, the default for 'tw' is zero, so you are not getting defaults. Perhaps some ftplugin used :set instead of :setlocal and you are getting the global value of the option. I think the rest of what I wrote is still on target.

Upvotes: 4

Related Questions