On 2025-02-28, David Mandelberg (Vim Github Repository) wrote: > 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.: > > https://github.com/vim/vim/blob/56957ed4109fb0c37922c6c37d5926cfe0a3313b/ > runtime/ftplugin/mail.vim#L20-L22 > > 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
I'm in a similar situation where I don't want any filetype plugin to set the 'o' in 'format options: autocmd FileType * setlocal formatoptions-=o I put this in my vimrc _after_ filetype plugin indent on so that it is executed after all the filetype plugins. You could something like this (untested): set tw=80 autocmd FileType * if &l:tw != 0 | setl tw=80 | endif I don't think you need to care that this is not executed for buffers with no file type because no filetype plugins will be sourced for them, either. Regards, Gary -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscr...@googlegroups.com. To view this discussion visit https://groups.google.com/d/msgid/vim_dev/20250228202311.GG10587%40phoenix.