首页 > 编程语言 > 详细

在Python命令行和VIM中自动补全

时间:2014-08-31 15:45:51      阅读:372      评论:0      收藏:0      [点我收藏+]

作者:gnuhpc
出处:http://www.cnblogs.com/gnuhpc/

1. VIM下的配置:

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

rm -f pydiction

确保文件结构如下:

# tree ~/.vim
/root/.vim
├── after
│   └── ftplugin
│       └── python_pydiction.vim
└── tools
    └── pydiction
        └── complete-dict
然后编辑~/.vimrc
# cat ~/.vimrc
filetype plugin on
let g:pydiction_location = ‘~/.vim/tools/pydiction/complete-dict‘
2. Python Console命令行:
# ~/.bashrc
export PYTHONSTARTUP=$HOME/.pythonstartup.py

#vim ~/.pythonstartup.py

try:
    import readline
    import rlcompleter
    import atexit
    import os
except ImportError:
    print "Python shell enhancement modules not available."
else:
    histfile = os.path.join(os.environ["HOME"], ".pythonhistory")
    import rlcompleter
    readline.parse_and_bind("tab: complete")
    if os.path.isfile(histfile):
        readline.read_history_file(histfile)
    atexit.register(readline.write_history_file, histfile)
    del os, histfile, readline, rlcompleter, atexit
    print "Python shell history and tab completion are enabled."

作者:gnuhpc
出处:http://www.cnblogs.com/gnuhpc/

在Python命令行和VIM中自动补全

原文:http://www.cnblogs.com/gnuhpc/p/3947709.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!