1

Is it possible to reload init.vim without quitting Vim (Neovim in my particular case, but I don't think it should be different)?

All the answers to this question that I've found here just say to re-source init.vim, however that doesn't seem to get rid of keybidings, functions, etc... that are already loaded.

I recently got rid of a plugin from my Neovim setup that had a conflicting keybinding, only to find that even though I had:

  1. modified and saved my config
  2. deleted the plugin directory
  3. and re-sourced my config

...the keybinding conflict was still there, with the additional failure that the called function couldn't be located.

1
  • 1
    depending on the mapping just :unmap should do it? Nov 9, 2022 at 19:41

1 Answer 1

1

thanks to Christian Brabandt in the comments for pointing me down the right path. :help unmap opens right above :help mapclear, which does what I need. My process is now:

  1. modify & save config
  2. delete plugin directory
  3. :mapclear (kills ALL keybindings)
  4. :so ~/.config/nvim/init.vim

:unmap will also work, if you happen to know ALL of the keybindings set by the deleted plugin. I'm not so careful or knowledgeable about the plugins I use...

4
  • 1
    Note that in general sourcing your vimrc file doesn’t reload plugin/*.vim files, so that may prevent some mappings from being created or other code from executing.
    – D. Ben Knoble
    Nov 9, 2022 at 22:32
  • Good point. I copped the idea of putting each plugins vim-plug line and configuration code in individual plugin/*.vim files from a youtube video by jess archer, so my init.vim sources all those files explicitly. it's made for a much cleaner init.vim than my previous monstrosity, so credit to her.
    – rreagan3
    Nov 11, 2022 at 3:33
  • 1
    Any file in plugin directories on the runtimepath is executed automatically… :sourceing or :runtimeing them without a guard means they are run twice.
    – D. Ben Knoble
    Nov 11, 2022 at 21:27
  • @rreagan3 I see how it's tempting to explicitly load plugins, however you'd probably better make use of vim's mecanism to do that, as stated by DBK.
    – Biggybi
    Nov 12, 2022 at 8:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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