vimvim-pluginvim-syntax-highlighting

In Vim, how to I set an autocommand to be run after a plugin has loaded?


One of the Vim Plugins I use has a bug, causing it to set :syntax spell notoplevel. The bug is easily mitigated if I run the command :syntax spell toplevel after opening a file. However, I'm lazy and I'd like to put the fix in my init.vim / .vimrc file, so that it's run automatically.

How can I ensure that my fix is executed after the buggy plugin code, so that my setting is not overridden by the plugin?


Solution

  • Create a file in ~/.vim/after/plugin/ such as ~/.vim/after/plugin/fix-spell.vim containing the command you'd run without the colon:

    syntax spell toplevel
    

    The files in ~/.vim/after/plugin are sourced after your plugins have loaded, thus providing a convenient hook to change settings that might have been set by a plugin.