3

One thing I hate about a lot of the default Vim plugins is that they add o to formatoptions. In Vim I would get around this by using au FileType * set formatoptions-=o in my vimrc, but for some reason this no longer works when using Neovim. How can I go about achieving this?

Details: Using Neovim 0.4.3 on neovim-qt

  • And does it work in vim for the same filetypes? – Maxim Kim Jan 24 at 6:55
  • You can use after directory to overwrite plugin defaults. It wouldn't be that simple -- you will have to care about every plugin in question, but should work. – Maxim Kim Jan 24 at 7:02
  • 1
    Try using a BufWinEnter event instead. That's a late event which should happen after all the filetype detection and setup is done. au BufWinEnter * set fo-=o. – filbranden Jan 24 at 7:09
  • 1
    sounds like a bug/regression to me – Christian Brabandt Jan 24 at 7:55
  • 1
    @filbranden thanks! If you post that as an answer I'll accept it. – Mason Jan 24 at 23:02
4

You can use a BufWinEnter event instead.

That's a late event, which should happen after all the filetype detection and setup is finished.

au BufWinEnter * set formatoptions-=o

The docs in :help BufRead suggest possibly using this event:

See BufWinEnter for when you need to do something after processing the modelines.

While your case is not directly about modelines, that was a hint that this event might be useful...

Please note this event may be triggered more than once for a specific buffer. If the command you're running is idempotent (which is the case with your command), that should be fine.

| improve this answer | |

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.