I do vim .vimrc and my vimrc opens with formatoptions=jcroql.

Then I do :source .vimrc and check the formatoptions again; they changed to tcq.

As far as I know there's nothing in my file that changes formatoptions... and even if there were it should already happen when I open it the first time, right? So how come it opens one way and when I source it it changes to another? Is this supposed to happen? How do I fix it?

  • Run :verbose set fo and see what set it last.
    – muru
    May 20 '16 at 21:37
  • @muru Last set from ~/.vimrc. Weird...
    – dbmrq
    May 20 '16 at 21:44

:h formatoptions says:

                                        'formatoptions' 'fo'
'formatoptions' 'fo'    string (Vim default: "tcq", Vi default: "vt")
                        local to buffer
                        {not in Vi}
        NOTE: This option is set to the Vi default value when 'compatible' is
        set and to the Vim default value when 'compatible' is reset.

So, if your vimrc contains set nocompatible, it's likely that caused Vim to set fo to the Vim default (tcq).

For example, try these commands:

set formatoptions=jcroql
set nocompatible
set formatoptions

The output is:

  • 1
    Ah, that's it, thanks! When I first open the file, vim.vim is sourced after vimrc, so the options are set right. So now I need a way to re-source the ftplugins after I source vimrc, so I can map a key to do both one after the other. Any ideas?
    – dbmrq
    May 20 '16 at 21:56
  • 2
    Probably set the filetype again? Something like :let &ft=&ft
    – muru
    May 20 '16 at 21:58
  • Yes, something like that... but unfortunately not that, it does nothing. And :set ft=&ft sets the filetype to "&ft".
    – dbmrq
    May 20 '16 at 22:02
  • 1
    Are you sure it does nothing? In my case, it resets fo to croql (my original setting for vim files).
    – muru
    May 20 '16 at 22:03
  • Oops, you're right! I must have made a typo or something. That's perfect, thank you!
    – dbmrq
    May 20 '16 at 22:05

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.