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?
Now you can place Vim plugins in ~/. vim/pack/vendor/start, and they'll automatically load when you launch Vim. A file tree will open along the left side of your Vim window. Any plugins installed into opt are available to Vim, but they're not loaded into memory until you add them to a session with the packadd command.
1. Introduction *autocmd-intro* You can specify commands to be executed automatically when reading or writing a file, when entering or leaving a buffer or window, and when exiting Vim. For example, you can create an autocommand to set the 'cindent' option for files matching *.c.
Nvim's data directory is located in ~/. local/share/nvim/ and contains swap for open files, the ShaDa (Shared Data) file, and the site directory for plugins. Starting from Nvim's version 0.5, it is possible to setup Nvim via Lua, by default ~/. config/nvim/init.
A file type plugin (ftplugin) is a script that is run automatically when Vim detects the type of file when the file is created or opened. The type can be detected from the file name (for example, file sample. c has file type c ), or from the file contents.
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.
Alternatively, you can set it as an autocommand. There are a whole slew of events you can tie autocommands to (:help events
for all of them). VimEnter is an event that fires after plugins are loaded, so you could set your command to run then with a line like this right in your vimrc:
autocmd VimEnter * syntax spell toplevel
That's what I am using to apply a plugin theme that is not available until after plugins load.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With