Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

UPDATE:

Here's my enhancement of the accepted answer:

augroup myft
  au!
  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
add comment

2 Answers 2

up vote 4 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
add comment

Found this:

http://peox.net/articles/vimconfig.html

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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.