[Reprint] enable the Python auto-completion and prompt function in VIM

Source: Internet
Author: User
Tags autoload



Reprint: http://zhongwei-leg.iteye.com/blog/941474



One of the reasons surrounding colleagues don't like using vim to write Python code is that VIM does not automatically complete and prompt like Visual Studio.
In fact, just vim is too low-key, we do not know.

Here's a look at Python omni complete, which looks like this when the installation is enabled:









1. How to install ' Python omni Complete ' plugin.



If it is VIM7.3, do not need to download Pythoncomplete.vim this plugin, because the installation comes with.
However, you must ensure that when you compile and install VIM, the Python feature is enabled, that is,


./configure--with-features=huge--enable-pythoninterp=yes


Because, Pythoncomplete.vim is written in Python.

We can see it in the Vim AutoLoad directory


ls -la /usr/local/share/vim/vim73/autoload/

    drwxr-xr-x  3 root root   4096 2011-02-16 16:29 .
    drwxr-xr-x 17 root root   4096 2011-02-16 16:29 ..
    -rw-r--r--  1 root root   3669 2011-02-16 16:29 adacomplete.vim
    -rw-r--r--  1 root root  22439 2011-02-16 16:29 ada.vim
    -rw-r--r--  1 root root  16938 2011-02-16 16:29 ccomplete.vim
    -rw-r--r--  1 root root  15922 2011-02-16 16:29 csscomplete.vim
    -rw-r--r--  1 root root   2998 2011-02-16 16:29 decada.vim
    -rw-r--r--  1 root root  23804 2011-02-16 16:29 getscript.vim
    -rw-r--r--  1 root root   5331 2011-02-16 16:29 gnat.vim
    -rw-r--r--  1 root root   6093 2011-02-16 16:29 gzip.vim
    -rw-r--r--  1 root root  24253 2011-02-16 16:29 htmlcomplete.vim
    -rw-r--r--  1 root root  27028 2011-02-16 16:29 javascriptcomplete.vim
    -rw-r--r--  1 root root  10130 2011-02-16 16:29 netrwFileHandlers.vim
    -rw-r--r--  1 root root   8684 2011-02-16 16:29 netrwSettings.vim
    -rw-r--r--  1 root root 338720 2011-02-16 16:29 netrw.vim
    -rw-r--r--  1 root root   1232 2011-02-16 16:29 paste.vim
    -rw-r--r--  1 root root 293714 2011-02-16 16:29 phpcomplete.vim
    -rw-r--r--  1 root root  21507 2011-02-16 16:29 python3complete.vim
    -rw-r--r--  1 root root  22019 2011-02-16 16:29 pythoncomplete.vim
    -rw-r--r--  1 root root    773 2011-02-16 16:29 README.txt
    -rw-r--r--  1 root root  23443 2011-02-16 16:29 rubycomplete.vim
    -rw-r--r--  1 root root   6184 2011-02-16 16:29 spellfile.vim
    -rw-r--r--  1 root root  30201 2011-02-16 16:29 sqlcomplete.vim
    -rw-r--r--  1 root root  16839 2011-02-16 16:29 syntaxcomplete.vim
    -rw-r--r--  1 root root  21145 2011-02-16 16:29 tar.vim
    -rw-r--r--  1 root root  12646 2011-02-16 16:29 tohtml.vim
    -rw-r--r--  1 root root  23031 2011-02-16 16:29 vimball.vim
    drwxr-xr-x  2 root root   4096 2011-02-16 16:29 xml
    -rw-r--r--  1 root root  14933 2011-02-16 16:29 xmlcomplete.vim
    -rw-r--r--  1 root root  11906 2011-02-16 16:29 zip.vim


If not, download the Pythoncomplete.vim and copy it to the ~/.vim/autoload/directory.

2. How to enable auto-completion
Add such two lines to the ~/.VIMRC


Set Omnifunc=pythoncomplete#complete


At this point, we have completed the installation and configuration work.

3. How to use auto-completion
For example, we enter


Import Sysprint sys.


At this point, press ctrl+x, Ctrl+o, you can see the prompt list box, as well as the corresponding docstring.
CTRL + N, ctrl+p up and down Select
ESC to cancel the prompt box.






4. Deficiencies
A. The attribute has no docstring, only functions have.
:( This seems to be a bad idea, because the attribute does not seem to docstring this concept.
B. In the absence of a drop-down box, there is no docstring



[Reprint] enable the Python auto-completion and prompt function in VIM


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.