On 2012-10-19, lessthanideal wrote:
> A lot of ftplugin files turn comment-wrapping on with a
> command like this:
> 
> set formatoptions+=c
> 
> I want to globally disable it.  Is there an easy way to do
> this?  I know I can disable it for particular filetypes by
> creating files in vimfiles\after\ftplugin\ specifying "set
> formatoptions-=c" but there are a lot of them.
> 
> Two methods I've found from searching are
> 
> . Maintain a single file and use symbolic links to make vim
> access it for each filetype.  A bit clumsy - new filetypes
> might appear later, I want to maintain real
> filetype-specific files as well, etc.
> 
> . Use autocmd events to set this.  This works in many cases
> but different edge cases are missed by different events so
> I'm not sure which events to use.  Also it seems to be
> "fighting vim" - trying to keep checking in case vim has
> changed the setting and change it back.  I'd like it to just
> work, reliably.
> 
> Is there a simpler method?

An autocommand should work.  The value of 'formatoptions' is only
going to be changed from your preferred setting by a filetype
plugin, and the sourcing of filetype plugins is triggered by a
FileType event, so all you have to do is have a FileType autocommand
that is executed _after_ all the filetype plugins have been sourced.
To do that, make sure to put your FileType autocommand in your
~/.vimrc _after_ your :filetype command, e.g.,

    filetype plugin indent on
    au FileType * setlocal formatoptions-=c

I've been using this technique to keep the 'o' flag unset and it has
worked fine.

Regards,
Gary

-- 
You received this message from the "vim_use" 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

Reply via email to