Python Auto-complement (VIM) _python

Source: Internet
Author: User
Tags readline

One, vim python automatic complement full plugin: pydiction

You can implement automatic completion of the following Python code:

1. Simple python keyword completion
2.python function Complement full bracket
3.python Module Completion
4.python module inner function, variable complement
5.from Module Import sub-module complement

For VIM to start automatic complement need to download the plugin, the address is as follows:

http://vim.sourceforge.net/scripts/script.php?script_id=850
Https://github.com/rkulla/pydiction

Installation configuration:

wget https://github.com/rkulla/pydiction/archive/master.zip
unzip-q master
MV Pydiction-master pydiction
mkdir-p ~/.vim/tools/pydiction
cp-r pydiction/after ~/.vim
CP pydiction/complete-dict ~/.vim/tools/ Pydiction

Make sure the file structure is as follows:

# Tree ~/.vim
/root/.vim
├──after
│└──ftplugin
│└──python_pydiction.vim
└──tools
└──pydiction
└──complete-dict

Create ~/.VIMRC to ensure that the contents are as follows:

# cat ~/.VIMRC
filetype plugin on let
g:pydiction_location = ' ~/.vim/tools/pydiction/complete-dict '

Use Vim to edit a py file, import os., this time should appear prompt, prove successful, the following figure

Second, the Python Interactive mode tab automatically padded

The file is created as follows:

# cat ~/.pythonstartup
# python startup file
#!/usr/bin/env python
import sys
import readline
Import rlcompleter
import atexit
import OS
# tab Completion
readline.parse_and_bind (' Tab:complete ')
# History File
histfile = os.path.join (os.environ[' home '], '. Pythonhistory ')
try:
  Readline.read_history_file (histfile)
except IOError:
  pass
atexit.register (readline.write_history _file, Histfile)
 
del os, Histfile, ReadLine, rlcompleter
1
	
echo ' export pythonstartup=~/. Pythonstartup ' >> ~/.bash_profile

Re-login The shell, enter the python command into interactive mode, you can use the TAB key to complement. The following figure:

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.