Python auto-completion (vim) and python auto-completion vim

Source: Internet
Author: User

Python auto-completion (vim) and python auto-completion vim

I. vim python Automatic completion plug-in: pydiction

The following python code can be automatically completed:

1. Simple python keyword completion
2. python function completion with parentheses
3. python module completion
4. Functions in the python module and variable completion
5. from module import sub-module completion

To enable auto-completion for vim, You need to download the plug-in:

Http://vim.sourceforge.net/scripts/script.php? Script_id = 1, 850
Https://github.com/rkulla/pydiction

Installation Configuration:

wget https://github.com/rkulla/pydiction/archive/master.zipunzip -q mastermv pydiction-master pydictionmkdir -p ~/.vim/tools/pydictioncp -r pydiction/after ~/.vimcp pydiction/complete-dict ~/.vim/tools/pydiction

Make sure that the file structure is as follows:

# Tree ~ /. Vim
/Root/. vim
── After
│ ── Ftplugin
│ ── Python_pydiction.vim
── Tools
── Pydiction
── Complete-dict

Create ~ /. Vimrc. Make sure the content is as follows:

# cat ~/.vimrcfiletype plugin onlet g:pydiction_location = '~/.vim/tools/pydiction/complete-dict'

Use vim to edit a py file, import OS. At this time, a prompt should appear to prove success, as shown in

Ii. Tab auto-completion in python Interaction Mode

The file to be created is as follows:

# cat ~/.pythonstartup# python startup file#!/usr/bin/env pythonimport sysimport readlineimport rlcompleterimport atexitimport os# tab completionreadline.parse_and_bind('tab: complete')# history filehistfile = os.path.join(os.environ['HOME'], '.pythonhistory')try:  readline.read_history_file(histfile)except IOError:  passatexit.register(readline.write_history_file, histfile) del os, histfile, readline, rlcompleter1echo 'export PYTHONSTARTUP=~/.pythonstartup' >> ~/.bash_profile

Log on to the shell again and enter the python command to enter the interactive mode. You can use the Tab key to complete the operation. For example:

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.