安装
[root@disconf ~]# wget https://github.com/rkulla/pydiction/archive/master.zip
[root@disconf liujiangbu]# unzip master.zip
[root@disconf liujiangbu]# cd pydiction-master/
[root@disconf pydiction-master]# ll
total 2572
drwxr-xr-x 3 root root 4096 Jan 6 2016 after
-rw-r--r-- 1 root root 2557737 Jan 6 2016 complete-dict
-rwxr-xr-x 1 root root 9986 Jan 6 2016 pydiction.py
-rw-r--r-- 1 root root 27465 Jan 6 2016 README
-rw-r--r-- 1 root root 27465 Jan 6 2016 README.md
[root@disconf pydiction-master]# mkdir -p ~/.vim/tools/pydiction
[root@disconf pydiction-master]# cp -r after ~/.vim
[root@disconf pydiction-master]# cp complete-dict ~/.vim/tools/pydiction
确保文件结构如下:
[root@disconf pydiction-master]# tree ~/.vim
/root/.vim
├── after
│ └── ftplugin
│ └── python_pydiction.vim
└── tools
└── pydiction
└── complete-dict
创建~/.vimrc,确保其中内容如下:
[root@disconf pydiction-master]# cat ~/.vimrc
filetype plugin on
let g:pydiction_location = '~/.vim/tools/pydiction/complete-dict'
找一个1.py文件试试,效果如下:
image.png交互模式补全:
[root@disconf ~]# cat ~/start.py
# 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
#echo 'export PYTHONSTARTUP=~/.pythonstartup' >> ~/.bash_profile
image.png
网友评论