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


    作者: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  
    (此变量指向的文件在python命令行启动时会自动加载)

    #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."

    更简单的方式是安装IPython

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

  • 相关阅读:
    thusc总结
    5.12总结
    5.9总结
    C语言学习之笔记
    C语言----------指针
    typedef , static和 extern
    数据库(mysql5.5)的一些基本的操作
    Java中基本数据类型占几个字节多少位
    java &和&& 以及 |和 ||之间的异同点
    拨开云雾见月明
  • 原文地址:https://www.cnblogs.com/gnuhpc/p/3947709.html
Copyright © 2020-2023  润新知