4

I'm aware of this question, but sourcing that way is not the same as restarting Vim. I want to do that without restarting Vim.

Like, if you have set fo+=c in your vimrc then re-sourcing changes it to something like this:

fo=<default_values>,c,c

How can I avoid this behavior? Is there any default config inside Vim that I could source before vimrc to get the same effect as a clean restart?

I'm using neovim.

MaikoID
  • 303
  • 2
  • 7

2 Answers2

5

I have not tried it, and I would not be surprised if it has some unexpected side effects, but you could try to add

set all&

at the top of your .vimrc file. This will reset all options to their default setting, cf. :h :set-&.

In particular, I am not sure how well this will work with respect to plugins. That is, some/many plugins set some vim options, and if you reset all options in your .vimrc file, and then resource the .vimrc file, then this might affect one or more of your active plugins.

A workaround might be to parse the output of :scriptnames and reload each of the loaded scripts in the given order. This should be done after the .vimrc file has been reloaded, and it should only happen after reloading, not upon restarting.

Karl Yngve Lervåg
  • 9,494
  • 25
  • 35
4

That is no problem:

:se[t] {option}+={value}

Add the {value} to a number option, or append the {value} to a string option. When the option is a comma separated list, a comma is added, unless the value was empty. If the option is a list of flags, superfluous flags are removed. When adding a flag that was already present the option value doesn't change.

This is described at :h :set+=

Christian Brabandt
  • 25,820
  • 1
  • 52
  • 77