运行环境: aliyun ECS Centos6.5_x64

一、vim python自动补全插件 pydiction

1.安装配置

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

创建 ~/.vimrc  新增内容如下:

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

此时用vi编辑python文件的时候,出现截图中的内容,表示已经成功。

wKiom1dFt__w3TeVAABE9MhYkis869.png

二、交互模式下自动补全

1.安装readline模块

yum -y install readline*

2.创建文件 ~/.pythonstartup

#python startup file.
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

3.添加到环境变量

export PYTHONSTARTUP=~/.pythonstartup

4.使配置生效

source ~/.bash_profile

此时在vim编辑模式下可以看到已经可以自动补全。