How do I override plugin or filetype settings that load after my vimrc?
Answer
~/.vim/after/ftplugin/{filetype}.vim
Explanation
Vim's after directory (~/.vim/after/) loads scripts after all plugins and standard runtime files. This lets you override any setting that a plugin or filetype plugin sets without modifying the plugin itself.
How Vim loads files
~/.vimrc— your config~/.vim/plugin/— plugin files$VIMRUNTIME/ftplugin/— built-in filetype plugins~/.vim/after/ftplugin/— your overrides (loaded LAST)
Override filetype settings
Create ~/.vim/after/ftplugin/python.vim:
setlocal tabstop=4
setlocal shiftwidth=4
setlocal expandtab
setlocal colorcolumn=88
Create ~/.vim/after/ftplugin/go.vim:
setlocal noexpandtab
setlocal tabstop=4
setlocal shiftwidth=4
Override plugin settings
Create ~/.vim/after/plugin/overrides.vim:
" Override any plugin's mappings or settings
silent! unmap <leader>x
nnoremap <leader>x :MyCustomCommand<CR>
Directory structure
~/.vim/after/
ftplugin/
python.vim " Overrides for Python files
go.vim " Overrides for Go files
javascript.vim " Overrides for JavaScript files
plugin/
overrides.vim " Global overrides for plugins
syntax/
python.vim " Syntax highlighting overrides
Tips
- Use
setlocal(notset) in ftplugin files —setaffects all buffers - The
after/directory is guaranteed to load after everything else - This is the proper way to fix filetype settings — not
autocmd FileTypehacks - In Neovim, the path is
~/.config/nvim/after/ - Check load order with
:scriptnamesto verify your after files load last - Documented under
:help after-directory