When I load certain file types in vim, the corresponding ftplugin adds "co" (among other options). I don't want this.

One example is the bundled ruby.vim. I could do this one ftplugin at a time by copying the file to ~/.vim/ftplugin/ and changing the set formatoptions line manually, but that is really inconvenient. Also, if I upgrade vim, I won't have the newest ftplugin files.

Is there a way to ignore only the "co" part for all ftplugins? Or maybe some way to have "set formatoptions-=co" run automatically after every ftplugin load?


Here's my enhancement of the accepted answer:

augroup myft
  au FileType * setlocal formatoptions-=c formatoptions-=o
augroup END

This defines the autocmd in a group, so the group can be cleared in case .vimrc is sourced multiple times. Otherwise the same autocmd will keep getting appended.

2 Answers 2


This was just answered recently by someone else, but I cannot find that answer, so here it is again. Put the following in your ~/.vimrc.

au FileType * setlocal formatoptions-=c formatoptions-=o

It's important to use separate -=c and -=o rather that -=co because the last will remove c and o only if they appear together in that order in 'formatoptions'.

  • Excellent. My trust in vim is restored :) .
    – Kelvin
    Commented Mar 15, 2012 at 18:51

Found this:


Looks like there's a way to set after-ftplugin hooks. But I still have to do that for every file type.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .