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.

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.

3

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+=

  • It does with the option formatlistpat that has a regex value, and there is others options that is does too. – MaikoID Jul 22 '16 at 20:32
  • 1
    @MaikoID that is a string option. It does not really make sense to use :set+= for that setting. – Christian Brabandt Jul 22 '16 at 20:44

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.