Using Jedi with YouCompleteMe

written on Monday, May 27, 2013 by

(In case you're not familiar with it yet, Jedi is an awesome autocompletion library for Python that tries to understand your code. There are editor plugins available for Vim, Emacs and Sublime Text 2.)

The "official" Jedi plugin for vim is jedi-vim, but there's another vim autocompletion plugin that supports Jedi: YouCompleteMe.

In contrast to jedi-vim, YCM does not only support Python, it also provides intelligent Clang-based completion support for C/C++/Objective-C/Objective-C++ as well as omnicomplete based semantic completions for Ruby, PHP and more.

The way YCM works is by automatically showing completion suggestions while typing, without the need for a trigger key. Another feature that distinguishes it from other autocompletion plugins is that the filtering of possible completions is not based on the prefix, but using subsequence matching instead. To quote the YCM author, this is a fancy way of saying that any input characters need to be present in a completion string in the order in which they appear in the input. So abc is a subsequence of xaybgc, but not of xbyxaxxc. And as yet another bonus, YCM features integration with UltiSnips.

More information and docs can be found at


To use YCM with vundle, simply add the following line to your .vimrc:

Bundle 'Valloric/YouCompleteMe'

Then let vundle install the new bundle:

$ vim +BundleInstall +qall

In order for YCM to work, you need to compile the core. Use the --clang-completer argument if you want semantic support for C family languages.

$ cd ~/.vim/bundle/YouCompleteMe
$ ./ --clang-completer


In my .vimrc I currently use only two configuration lines. The first enables auto closing of the preview window when the user accepts the offered completion string.

let g:ycm_autoclose_preview_window_after_completion=1

The next line maps Jedi's jump to definition/declaration feature to the <leader>g shortcut:

nnoremap <leader>g :YcmCompleter GoToDefinitionElseDeclaration<CR>

Further Information

jedi-vim and YCM are currently not compatible. You have to choose one of them.

YCM's integration with Jedi is still under development. As soon as all features are implemented (pydoc is not included yet, for example), it might even replace jedi-vim as the "officially endorsed" completion plugin. You can find more information in jedi-vim issue #119.

For more information about YCM, refer to its extensive documentation.

This entry was tagged python and vim