I currently set textwidth=80 in my vimrc because I want that to be the default if there's nothing filetype-specific. But some ftplugins won't set textwidth after that line in my vimrc, e.g.:
I'm currently just adding lines like setlocal textwidth=72 to my ~/.vim/ftplugin/mail.vim to get the per-filetype defaults, but it would be nice to not need to do that for every filetype that sets textwidth in that way. Is there any way to leave textwidth at 0 initially, but set it to 80 after ftplugins are run if it's still 0 and hasn't been explicitly set to 0 by the ftplugin? I was thinking of using the FileType event, but that doesn't seem to trigger for buffers with no filetype, which does make sense.
If that's not possible, would it make sense to add a new option like g:prefer_filetype_textwidth so that mail.vim and similar ftplugins could do this instead?
if &tw == 0 || g:prefer_filetype_textwidth setlocal tw=72 endif
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
That does the opposite of what I want. That would make my preference for 80-by-default override the filetype plugins, but I want the filetype plugins to override my preference.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you commented.![]()
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
Yeah, it's not worth a lot of work in my personal configs for this. There are only a handful of files that do it, and I've already added overrides for each one.
$ grep -r 'if.*&\(tw\|textwidth\)' -- runtime/ftplugin/
runtime/ftplugin/changelog.vim: if &textwidth == 0
runtime/ftplugin/mail.vim:if &tw == 0
runtime/ftplugin/vim.vim:if &tw == 0
runtime/ftplugin/hamster.vim:if &tw == 0
runtime/ftplugin/verilog.vim:if &textwidth == 0
If this is something other people want, then I think changing each of those to something like if &tw == 0 || g:prefer_filetype_textwidth would be the simplest option. If I'm the only one who cares, then I'll keep overriding it for those filetypes in my dotfiles.
(I only started looking into this in the first place because I've been trying to go through my dotfiles and contribute anything upstream that would be useful to other people. With the side benefit of getting rid of code from my dotfiles after upstreaming it.)
—
Reply to this email directly, view it on GitHub.
You are receiving this because you commented.![]()