I am trying to use this plugin

I have created a copy of xml.vim and named it html.vim.

The problem is that the system ftplugin C:\Program Files (x86)\Vim\vim74\ftplugin\html.vim is loaded before the new one.

I have checked this with :scriptnames.

Once the default html.vim is loaded the custom one will NEVER work - even if loaded after. My only way of fixing has been to remove/replace the default one with the custom one.

This works fine but I don't like having to edit the system files. Feels like too much of a hack.

Please note that using /ftplugin/after does not work because the default still gets loaded first and that seems to irretrievably break the custom ftplugin functionality.

On a side note: i would really like the try the more recent xmledit plugin but don't know how to compile the vimball on Windows and I use Vundle (not Pathogen). Help on that front would be great too!

  • "that seems to irretrievably break the custom ftplugin functionality." <- In what way?
    – Rich
    Feb 24, 2016 at 14:44
  • 1
    To install xmledit with Vundle, you should just need to add the line Plugin 'sukima/xmledit' to your .vimrc. Does that not work?
    – Rich
    Feb 24, 2016 at 15:15
  • Just to be clear, are you putting your version of html.vim into ~/.vim/ftplugin or somewhere else? Feb 24, 2016 at 20:18
  • @dash-tom-bang That's right. I was putting it in ~/.vim/ftplugin
    – Fonnae
    Mar 11, 2016 at 14:30
  • @Rich I say it irretrievably breaks the functionality because when I (re)set the filetype of something I'm editing, which I think causes Vim to reload the corresponding ftplugin, it still does not enable the functionality. IOW, I can understand that the default plugin is overriding the custom one, but after reloading the custom one I would expect it to override the default and give me the missing functionality but it does not. Perhaps my understanding is completely off.
    – Fonnae
    Mar 11, 2016 at 14:34

2 Answers 2


Overriding a plugin manually

Unless you intend to change all of the settings set by Vim's existing html ftplugin, you want your plugin to be loaded before it. The setting of the b:did_ftplugin variable will then cause Vim's version to exit immediately.

Placing the plugin in your ~/.vim/ftplugin directory will cause it to be loaded before Vim's included version.

Vim's help discusses this in :help ftplugin-overrule:

  1. Make a copy of the plugin and change it.

    You must put the copy in a directory early in 'runtimepath'. For Unix, for
    example, you could do this:

    cp $VIMRUNTIME/ftplugin/fortran.vim ~/.vim/ftplugin/fortran.vim

    Then you can edit the copied file to your liking. Since the b:did_ftplugin
    variable will be set, the global plugin will not be loaded.

Using Vundle

However, the first sentence of your question states that your goal is simply to use this plugin, and the last sentence states that you use Vundle.

If this is the case, then all you need to do to use the plugin is add the following line to your .vimrc file:

Plugin 'othree/xml.vim'
  • I did not know Vundle could be used because I did not see specific instructions for that in the README of the plugin. I have since tried it and it worked perfectly. Similarly, I would have used xmledit but did not see Vundle instructions for that either. How do you know when a plugin is compatible with Vundle?
    – Fonnae
    Mar 11, 2016 at 14:43
  • I did not try your suggestion for overriding ftplugins and since that is the exact title of the question I am unsure whether to mark the answer as correct :/ Thanks a bunch though
    – Fonnae
    Mar 11, 2016 at 14:48
  • 1
    @Fonnae Glad you've got it working. Almost all plugins are compatible with Vundle, so the vast majority of them won't bother specifically mentioning that they are compatible. Your best bet for understanding how to install plugins with Vundle is to read :help vundle, rather than looking for instructions in each individual plugin's documentation.
    – Rich
    Mar 11, 2016 at 16:44

On Windows, $HOME/vimfiles/after/ftplugin/foobar.vim runs after loading the standard foobar ftplugin.

  • 1
    Yeah, in my case I've just moved from "after/ftplugin" to just "ftplugin" directory, by the way, the word "after" means: load this after the system defaults :) Jan 17, 2020 at 13:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.