简体   繁体   中英

Python omnicompletion in Vim editor not working

I am trying to use vim on my Python journey, based on this guide .

I think I have the same problem as a paid nerd but since they didn't find a solution I am posting again here.

For some reason I can't get omnicompletion to work in vim, with python. I have installed the fabulous R-plugin and built the tags list. So I get omnicompletion with R.

But not for Python. A few observations:

  1. :echo &omnifunc prints pythoncomplete#Complete .
  2. the .vim/doc/tags file has R tags, but no python (but this is because python is supported by default right?)
  3. If I do import math in my .py file I can autocomplete eg. ma to math. but no methods are found?

How can I proceed?

It appears that the default omnicompletion for python ( pythoncomplete#Complete ) does not know about buildins/keywords.

When you Ctrl-X Ctrl-O on math. (if you have imported "math") you should see the available math. functions but to do so for print , sorted etc I think you need a plugin like:

There are a number of plugins for python completion. The vim python filetype plugin appears to be the best at this point. It requires a vim built with python support, and should otherwise work out of the box. Completion of system modules will just work, and you'll their methods in omnicompletion.

I assume all modules you are importing are in Python path, right? Check if all of your imports in this file are working, in my case one failing import (syntax error in module being imported) broke omnicompletion.

check ~/.vim directory ,inside doc directory you should have NERD_tree.txt, so you should have nerd tree plugin installed. . .

.vim/doc/tags contains tags for the Vim documentation (including the R plugin), and this has nothing to do with the tags used for completion. You can regenerate them using

:helptags ~/.vim/doc

When it comes to completion, which keyboard shortcut do you use? By default the omni-complete is bound to Ctrl-X Ctrl-O , not the usual Ctrl-N .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM