Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Yesterday I came across jedi-vim plugin which provides auto-completion for python. I installed the plugin using pathogen by placing it in bundle directory and it is working fine.

Now, as I have mentioned that this plugin is only for filetype: python so I want to load it only when I open files with .py extensions and not when I open other files like .java, .perl, .sh.

So, how can this be achieved.

I am a vim beginner/noob but I googled before asking and found that this can be achieved using vim ftplugin but I have no idea whatsoever where to place which file.

share|improve this question

migrated from Oct 21 '12 at 9:40

This question came from our site for professional and enthusiast programmers.

As the writer of jedi and jedi-vim I ask you: why do you want to do this? – David Halter Oct 19 '12 at 19:09
I was about to ask the same thing about plugins. Probably it is fine with jedi-vim, but I have a couple of really simple plugins which are loaded independently of the file type. But when I get more complex plugin solution for a specific file type(for example jedi-viim) I would like to have only it loaded and prevent the simple plugins from messing around. What I need is more like blacklist of file types per plugin, not a whitelist. – egelev Jun 16 '15 at 12:06

Especially for complex plugins, the plugin must be written in a way that minimizes its effects on other filetypes. You didn't state why you want to limit the plugin's application to Python files (as long as it doesn't install global mappings that interfere with other mappings, you'd normally not care), but after finding an issue about slow loading time, I suspect it's that.

Until the plugin author provides a fix, you can try moving the plugin/jedi.vim file (and the corresponding one directory up, so that it isn't sourced automatically when Vim starts. When you want to use the plugin, load it via :runtime jedi.vim. Maybe you can even move the files into the ftplugin/ folder; they would then be automatically sourced when a Python file is edited; try it out.

Alternatively, you could completely separate the .vim directories for Python and other development, and use two different aliases to start vim-with-python vs. plain vim:

alias vim-with-python='vim --cmd "set rtp^=~/.vim-with-python" --cmd "set rtp+=~/.vim-with-python/after"'
share|improve this answer
By one directory up you mean moving it from bundle/jedi-vim/plugin to bundle/jedi-vim b'coz this didn't worked. it showed some errors saying undefined variable ... – ronnie Oct 18 '12 at 7:58
Yes, actually, any directory outside plugin/ is fine, because only those are sourced on startup. But as I said, for complex plugins spread over many files, this may not be so easy; you'd have to reverse-engineer the dependency structure and calling sequence. – Ingo Karkat Oct 18 '12 at 9:27

There are plugin managers for Vim that do this

For your example in vim-plug.

Plug 'davidhalter/jedi-vim', {'for': 'python'}

where the string is the author/name of the github repository. All scripts from are also rehosted on github via under the user vim-scripts

share|improve this answer

You must log in to answer this question.