I'd like to configure Vim 8.2
on Ubuntu 18
so that when I open code in different programming languages, different settings load. Eg. indentation, color-theme, plugins etc.
I found ftplugin
to be the recommended way to achieve this setup. Let's assume I want to setup VIM for python and markdown. I've installed the plugins (NERDTree, ale etc.) using VIM's native package manager. I've put some plugins like NERDTree in the /start
folder while some like ALE in the /opt
folder. This is because I want NERDTree to always load when I open any file using VIM while I want to conditionally load ALE when I only open a python file (and not markdown).
From what I've read in other answers and blogposts, we need to do the following -
- Add
filetype plugin indent on
at the start of the main~/.vimrc
. - Create folders
~/.vim/ftplugin/python.vim
and~/.vim/ftplugin/markdown.vim
.
"file => ~/.vim/ftplugin/python.vim
setlocal number
setlocal autoindent
setlocal shiftwidth=4
packadd! ale
"file => ~/.vim/ftplugin/markdown.vim
setlocal number
setlocal autoindent
setlocal shiftwidth=2
What will be the difference between adding ftplugin
in the /after
directory ie. ~/.vim/after/ftplugin/markdown.vim
as opposed to ~/.vim/ftplugin/markdown.vim
?