The example I am following is from the book The VimL Primer Chap 4.
In the ftdetect
dir I have the following line:
autocmd BufRead,BufNewFile *.mpdv set filetype=mpdv
In a file called mpdv.vim
However this command is not executed when I open a mpdv file. In .vimrc I have:
filetype plugin on
The way im loading the plugin is the following: In ~/.vimrc I have:
set exrc
This forces vim to load local .vimrc files
Then in my projects pluginfolder i have the follwoing .vimrc
set runtimepath+=path/to/my/plugin
What can I do the debug why vim is not loading my autocmd when I open a mpdv file?
One thing I've noticed (and which seems to be the deal with your case as well) is that if you add new path on runtimepath, you should have the filetype plugin on
done after updating the runtimepath.
For example, with the following vimrc, it would work fine:
set runtimepath+=/home/techgaun/fun/vim/mpc
filetype plugin indent on
And, if you run :scriptnames
, you should see the ftdetect script loaded fine from your mpc plugin directory.
In my case, vim appeared to not be sourcing the files under the ftdetect
and ftplugin
directories in the custom runtimepath. I tried putting the directories under my .vim
folder:
.vim
├── autoload
│ └── mpc.vim
├── ftdetect
│ └── mpdv.vim
├── ftplugin
│ └── mpdv.vim
└── plugin
└── mpc.vim
Now the script under ftdetect
runs, as can be seen when I run :scriptnames
:
1: /usr/share/vim/vimrc
2: /usr/share/vim/vim74/debian.vim
3: ~/.vimrc
4: /usr/share/vim/vim74/filetype.vim
5: ~/.vim/ftdetect/mpdv.vim
6: /usr/share/vim/vim74/ftplugin.vim
7: /usr/share/vim/vim74/syntax/syntax.vim
8: /usr/share/vim/vim74/syntax/synload.vim
9: /usr/share/vim/vim74/syntax/syncolor.vim
10: ~/.vim/plugin/mpc.vim
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