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: