Why does Vim ignore files in ~/.vim/after/ftplugin?

19

3

I seem to have a problem with my local Vim configuration but I'm not sure what it is. I need to override some filetype-specific settings. As per multiple tutorials/howtos, I created ~/.vim/after/ftplugin/cpp.vim with appropriate setlocal statements, but it seems not to be read. I checked that ~/.vim/after is in runtimepath.

I worked around this with autocmd FileType cpp setlocal ... in ~/.vimrc, but that is beyond the point. Any advice on how to diagnose/fix this? Or am I just overlooking something obvious?

AdSR

Posted 2010-07-23T14:19:30.740

Reputation: 193

Answers

19

Check the output of:

:filetype

You may need to add

filetype plugin on

to your .vimrc (or at least add 'plugin' to your 'filetype' setting).

jinfield

Posted 2010-07-23T14:19:30.740

Reputation: 391

10

A good place to start would be to use the :scriptnames command. Open a C++ file however you normally do and execute

:scriptnames

This will show you the files that Vim has sourced since it was started.

garyjohn

Posted 2010-07-23T14:19:30.740

Reputation: 29 085

1That's a useful tip for debugging. I used to run vim --cmd 'set verbose=2' in order to see which script files were being sourced. – Anthony Geoghegan – 2016-11-24T15:42:22.283

Yes, very useful. I learned that, the load-order of after-plugins is not what you would think, see answer https://vi.stackexchange.com/a/20227/20753 about that.

– Jari Turkia – 2019-06-06T06:00:54.233