您的位置:首页 > 编程语言 > Python开发

如何在配置vim的(Python)代码自动补全功能

2010-06-30 08:07 861 查看
Description
===========
Pydiction allows you to Tab-complete Python code in Vim, including keywords, the standard library, and third-party modules.

It consists of three main files:

python_pydiction.vim -- This is an ftplugin you put in your non-system ftplugin directory (i.e., ~/.vim/after/ftplugin/, on Unix or C:/vim/vimfiles/ftplugin/, on Windows)
complete-dict -- This is a vim dictionary file that consists of Python keywords and modules. This is what python_pydiction.vim looks at to know which things are completable.
pydiction.py -- (Not required) This is a Python script that was used to generate complete-dict. You can optionally run this script to add more modules to complete-dict.

Install Details
===============
Unix/Linux: Put python_pydiction.vim in ~/.vim/after/ftplugin/ (If this directory doesn't already exist, create it. Vim will know to look there automatically.)
Windows: Put python_pydiction.vim in C:/vim/vimfiles/ftplugin (Assuming you installed Vim to C:/vim/).

You may install the other files (complete-dict and pydiction.py) anywhere you want. For this example, we'll assume you put them in "C:/vim/vimfiles/ftplugin/pydiction/" (Do not put any file but python_pydiction.vim in the ftplugin/ directory, only .vim files should go there.)

In your vimrc file, first add the following line to enable filetype plugins:

filetype plugin on

then make sure you set "g:pydiction_location" to the full path of where you installed complete-dict, i.e.:

let g:pydiction_location = 'C:/vim/vimfiles/ftplugin/pydiction/complete-dict'

You can optionally set the height of the completion menu by setting "g:pydiction_menu_height" in your vimrc. For example:

let g:pydiction_menu_height = 20

The default menu height is 15.

1:将python_pydiction.vim文件拷贝到d:/vim/vimfiles/ftplugin中

2:将complete-dict拷贝到d:/vim/vimfiles/ftplugin/pydiction/complete-dict中

3:编辑.vimrc 文件,增加如下:

"pydiction 1.2 python auto complete
filetype plugin on
let g:pydiction_location = 'd:/vim/vimfiles/ftplugin/pydiction/complete-dict'
"defalut g:pydiction_menu_height == 15
"let g:pydiction_menu_height = 20
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: