在vim中给python加上代码提示功能

去下载pydiciton:

http://vim.sourceforge.net/scripts/script.php?script_id=850

下下来的是一个zip包,里边有三个文件。

 

(1)python_pydiction.vim

这个是plugin文件

 

我的vim装在d:/home/vim

必须放在D:\home\vimfiles\ftplugin目录,这个目录已经存在的。不知道什么时候就有的。。。

 

(2)complete-dict

这个是词典文件里边存放了需要提示的关键字。

扔到了D:\home\vimfiles\ftplugin\pydiction目录下

 

(3)pydiction.py

这个没什么用,运行这个脚本增加更多的python module到词典文件

扔到了D:\home\vimfiles\ftplugin\pydiction目录下

 

2,3两个文件扔哪都无所谓,但是ftpplugin目录下只能放.vim文件,所以如作者所愿建了个pydiction子目录放了进去。

 

最后编辑你的.vimrc文件,追加如下参数:

"================= content assistant plugin =============
filetype plugin on 
let g:pydiction_location = 'D:/home/vimfiles/ftplugin/pydiction/complete-dict'
let g:pydiction_menu_height = 15
 

 

 

 

三个参数的解释如下:

In your vimrc file, first add the following line to enable ftplugins:
  
        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.

 

 

最后看看怎么用吧。简单来说就是在敲代码的过程中按tab键 #_!

 

比如敲
        raw<Tab>

就会提示
        raw_input(
        raw_unicode_escape_decode(
        raw_unicode_escape_encode(

此时想取消请按Ctrl+E

确认的话什么都不用按或者按Ctrl+Y(总是忍不住要按一下Enter)

继续按tab可以切换到其它option(也可用方向键。。)

闲得蛋疼的话就看看这里:http://vim.sourceforge.net/scripts/script.php?script_id=850

会知道的更多。。

 

 

 

参考:http://www.pythonclub.org/python-basic/vim

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值