Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
up vote 5 down vote accepted

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'.

share|improve this answer
Excellent. My trust in vim is restored :) . – Kelvin Mar 15 '12 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.

share|improve this answer

You must log in to answer this question.

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