vimでpythonの補完を行う

pythonを少し書いてみようと思い立ち、とりあえずvimでpythonのキーワードを補完できるようにしてみました。

補完するには、Pydiction というプラグインを使いますので、zipファイルをダウンロードします。

今回はバージョン1.2を使い、以下のようにインストールしました。

# unzip pydiction-1.2.zip
# mkdir ~/.vim/plugin/
# mkdir ~/.vim/pydiction
# mv pydiction-1.2/python_pydiction.vim ~/.vim/plugin/
# mv pydiction-1.2/complete-dict ~/.vim/pydiction

あとは、vim でプラグインを使用できるようにと、その他もろもろの設定を、~/.vimrc に追記します。

# vi ~/.vimrc
filetype plugin on
autocmd FileType python let g:pydiction_location = '~/.vim/pydiction/complete-dict'
autocmd FileType python setl autoindent
autocmd FileType python setl smartindent cinwords=if,elif,else,for,while,try,except,finally,def,class
autocmd FileType python setl tabstop=8 expandtab shiftwidth=4 softtabstop=4

あとは、プログラミング中にTABで補完が効きます。

python_pydiction.vim
タイトルとURLをコピーしました