Python auto-complete
Python automatically complements all of the vim editing and Python interactive modes, and below describes how to implement tab completion in these 2 situations.
One, vim python automatic completion plug-in: pydiction
You can implement the following Python code auto-completion:
Simple python keyword completion
Python function completion with parentheses
Python Module completion
Python module inner function, variable completion
From module import sub-module complement
To start AutoComplete for vim, you need to download the plugin at the following address:
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
Ensure that the file structure is as follows:
# tree ~/.vim/root/.vim├──after│ └──ftplugin│ └──python_pydiction.vim└──tools └──pydiction └── Complete-dict
Create a ~/.VIMRC to make sure the contents are as follows:
# cat ~/.vimrcfiletype plugin Onlet g:pydiction_location = ' ~/.vim/tools/pydiction/complete-dict '
Use Vim to edit a py file, import os., this time should appear prompt, prove success, such as
Second, the Python Interactive mode tab auto-completion
Create the file 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 to the shell, enter the python command into interactive mode, you can use the TAB key to complete the completion. Such as:
Of course, there are other ways to do the same.
Linux tab and Shell complement Python