美文网首页
linux-centos-vim编辑*.py文件自动补全

linux-centos-vim编辑*.py文件自动补全

作者: 老夫刘某 | 来源:发表于2017-10-12 11:43 被阅读0次

    安装

    [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

    相关文章

      网友评论

          本文标题:linux-centos-vim编辑*.py文件自动补全

          本文链接:https://www.haomeiwen.com/subject/lwmnyxtx.html