Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1113714
  • 博文数量: 309
  • 博客积分: 6093
  • 博客等级: 准将
  • 技术积分: 3038
  • 用 户 组: 普通用户
  • 注册时间: 2008-02-03 17:14
个人简介

linux学习记录

文章分类

全部博文(309)

文章存档

2014年(2)

2012年(37)

2011年(41)

2010年(87)

2009年(54)

2008年(88)

分类:

2011-04-11 09:57:22

这是一个相当不错的 Python 代码自动完成的脚本。

可以实现下面python代码的自动补全:

  1. 简单python关键词补全
  2. python 函数补全带括号
  3. python 模块补全
  4. python 模块内函数,变量补全
  5. from module import sub-module 补全

适用VIM7之后的版本。

将文件 python_pydiction.vim 放到 ~/.vim/after/ftplugin/ 路径下,如果这个路径不存在,你可以自己创建这个文件夹结构。(Windows下面的话放在目录类似的结构中)

将complete-dict文件放到你自己的某个路径下,后面的配置会用到这个文件,这个文件就是记录所有的python关键词。

我将这个文件放到 ~/.vim/tools/pydiction/complete-dict

在 ~/.vimrc 文件中添加如下配置

"pydiction 1.2 python auto complete
filetype plugin on
let g:pydiction_location = '~/.vim/tools/pydiction/complete-dict'
"defalut g:pydiction_menu_height == 15
"let g:pydiction_menu_height = 20

为了使用这个功能,我把pydiction 放在了 ~/.vim/tools 目录中,并在 .vimrc 中增加如下设置:

" python auto-complete code
" Typing the following (in insert mode):
" os.lis
" will expand to:
" os.listdir(
" Python 自动补全功能,只需要反覆按 Ctrl-N 就行了
if has("autocmd")
autocmd FileType python set complete+=k~/.vim/tools/pydiction
endif

pydiction 1.2 版本在VIM中直接用 键就可以实现自动补全。

vim中键入 os.pa 后出现的自动补全界面

  • 本地下载:
  • 官方地址:
阅读(577) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~