I would like a textwidth of 80 by default in vim, but if specific filetypes have their own text width (in particular gitcommit where tw=72) I would like vim to honour that width.
In my .vimrc I have the line:
set tw=80
I have also tried
setlocal tw=80
However this seems to override the gitcommit width of 72.
If I remove the line then git commits work fine (wrap at 72) but a text file (for example) will not wrap automatically.
Is it possible to have vim wrap to 80 if nothing else is specified, but otherwise follow the specific filetype instructions?
As an aside, I think this used to work up until recently. I have tried removing everything else from my .virmrc but the set tw=80, but this doesn't make any difference.
EDIT: If I open up a git commit message editor, and run
:verbose set tw?
vim displays:
textwidth=80
Last set from ~/.vimrc