Update:
I am now also using YouCompleteMe. You may need to check that too!


Here is the story: You have decided to work with python and vim but you would like code assistance (autocomplete, syntax highlighting etc).

I came to that point when I wanted to work with tensorflow, I had trouble installing it on a Mac and decided to go for the Docker container solution.

I was neither a Docker container nor a python expert at that time, so I could not install visual IDEs and decided to use vim for development.  As I was hooked to code assistance in any IDE I had been using, I wanted to have that with python and vim as well.

To cut a long story short, let’s try to install code assistance for python in vim and also make it aware of the tensorflow framework.

My environment is an Ubuntu 14.04, the one that came with the tensorflow container.

VIM

If vim is not installed go ahead and install it

$ sudo apt-get install vim

Pydiction

What you need next is pydiction, a python tool that allows you to autocomplete your code in vim with the tab key (among other keyboard shortcuts)

Installing it is super easy and instructions are provided here.
Once you are done Play around a bit with some python commands (print, while, etc) to verify that it works.

However, it is not ready to auto-complete code from fancy frameworks yet. For example, if you would like it to code assist you with a command like this

tensorflow.initialize_all_variables()

​it will not.

The reason is, that pydiction does not parse any libraries and directories to lookup your code and complete it.

It is based on a static dictionary file named compete-dict. So, in order to extend its use into the frameworks we work with, we must populate it with their contents.

Although this may sound like a daunting task, the creators of pydiction made it very easy for us.
Just do

$ python pydiction.py <framework name>

​For tensorflow I did

$ python pydiction.py tensorflow

​and it worked like a charm.