天天看點

python的tab自動補全

很久不寫blog了。

最近發現python的自動補全是個好東西。

分享一下。

直接粘貼了。

------------------------------

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

本文轉自 sharkyan 51CTO部落格,原文連結:http://blog.51cto.com/sharkyan/1529796,如需轉載請自行聯系原作者

繼續閱讀