For example, I have a Python script using the Google App Engine SDK:
from google.appengine.ext import db
from google.appengine.ext import webapp
from google.appengine.ext.webapp import template
from google.appengine.ext.webapp.util import run_wsgi_app
The module db
has a submodule Key
, so I try to use autocomplete on it:
db.K
Tab
But at the bottom of the Vim window, I get the following:
-- Omni completion (^O^N^P) Pattern not found
How do I include the path to non-standard Python libraries so that Vim autocompletion can find them? And also display their docstrings?
To use it, simply press [ctrl] + n or [ctrl] + p key while in edit mode. For example: However, we can *teach* vim to autocomplete much other stuff by using so-called Dictionaries. We can have auto-completion for Python, Ruby, PHP, Bash, and any other programming languages code with this idea.
Beginning version 7, Vim started to introduce its auto-complete feature. By default, it works by auto-completing words that already existed in the file being edited. If enabled, it can also auto-complete syntax for various programming languages. To make the list cycle backwards, hit Ctrl + p.
file. to enter the *edit* mode and type any JavaScript keyword in the text editor and press *Ctrl + x* followed by *Ctrl + o*. Vim editor will show the possible auto-complete suggestions. document.
(In Python Shell window, you can use TAB key besides the key combination of 'CTRL' and 'space' to invoke the built-in auto-completion feature.) Alternatively, you can choose the "Show Completions" in the main Edit menu to achieve the same as well.
You need to add your library files to your tags file. For instance, if you have installed the Google App Engine via pip in a virtual environment located in env/:
virtualenv --no-site-package env/
source env/bin/activate
pip install google_appengine
... then you should execute:
ctags -R --python-kinds=-i -o tags env/
If you did not install google_appengine through pip, then you should locate the path to your python libraries (hint: it should be indicated by $PYTHONPATH. And according to this reference page: "on Unix, this is usually .:/usr/local/lib/python.") and replace env/ by the path you found.
Finally, your .vimrc file should parse your tags file. For instance, in my .vimrc, I have:
set tags+=/path/to/my/tags
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With