3

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.

2 Answers 2

5

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

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

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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