很久不寫blog了。
最近發現python的自動補全是個好東西。
分享一下。
參考了:http://www.cnblogs.com/allenblogs/archive/2011/04/21/2023288.html 和 軟件手冊
下載地址:http://vim.sourceforge.net/scripts/script.php?script_id=850
直接粘貼了。
------------------------------
vim編輯器中
#mkdir -p ~/.vim/after/ftplugin/
#mkdir -p ~/.vim/bundle/pydiction/
#unzip pydiction-1.2.3.zip
#cd pydiction
#cp after/ftplugin/python_pydiction.vim ~/.vim/after/ftplugin/
#cp complete-dict ~/.vim/bundle/pydiction/
#cp pydiction.py ~/.vim/bundle/pydiction/
#vim ~/.vimrc
filetype plugin on
let g:pydiction_location = '~/.vim/bundle/pydiction/complete-dict'
let g:pydiction_menu_height = 3
python交互模式下
#cat python-tab-completion.sh
#!/bin/bash
cat >> ~/.python-tab-completion.py <<EOF
#!/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
EOF
echo 'export PYTHONSTARTUP=~/.python-tab-completion.py' >> ~/.bashrc
#bash python-tab-completion.sh