14
5
In my .vimrc
I am trying to use ftplugin
and obviously use some commands relating to that under the assumption that it was loaded successfully. However, I have now encountered a few old machines that don't have the plugin installed. Can I somehow make loading of this plugin conditional and add filetype on
and similar directives into the same conditional block?
I have seen there are conditions for color schemes and the Vim version, but I haven't seen an example that would check for the plugin (or didn't recognize it).
NB: Be gentle, I am a VimScript beginner.
1Note that plugins are loaded after your
~/.vimrc
, so you won't be able to test for the effects of a plugin within your~/.vimrc
unless you test for the existence of the plugin file or defer the test until after plugins have been loaded with an autocommand such as VimEnter. – garyjohn – 2013-02-15T01:16:32.787@garyjohn: aha, that's interesting. Because this kind of contradicts the existing answer. Could you write it up as an answer? – 0xC0000022L – 2013-02-15T01:51:59.887
I've edited my answer to somewhat address that issue. – qqx – 2013-02-15T02:10:30.140
My comment didn't contradict qqx's answer; it was meant to draw attention to a point that could have been missed if one didn't read qqx's answer carefully or made incorrect inferences from it. The answer was good to start with and is even clearer now. – garyjohn – 2013-02-15T03:08:29.177