Vim与Python:上下文无关的语言方法自动完成功能
我正在写一个小的Python脚本,目的是学习VIM的基础知识(我还是VIM的新手)。
我已经配置好VIM可以使用自动补全功能,而且它确实可以工作。
比如说,当我输入str.然后按下ctrl+x和ctrl+o时,它会给我推荐所有的字符串方法。
但是在我的代码中,有这样的内容:
for line in inFile.readlines():
something = line.rpartition(" ")[0]
我希望VIM在我输入line.rpart之后能自动补全rpartition这个方法名。我并不指望它能知道line对象的类型,但我希望VIM能根据Python库的知识,给我提供一个不考虑上下文的补全列表。
比如说,如果我在Eclipse中尝试补全:
anObject.rpart
它会给我推荐rpartition这个方法,即使它和anObject没有任何关系!
请问在VIM中能做到这一点吗?
谢谢。
我的.vimrc文件:
set showcmd
set textwidth=80
set expandtab
set smarttab
set tabstop=4
set shiftwidth=4
set softtabstop=4
set number
set autoindent
filetype indent on
filetype plugin on
autocmd BufRead,BufNewFile *.py syntax on
autocmd BufRead,BufNewFile *.py set ai
autocmd BufRead *.py set smartindent cinwords=if,elif,else,for,while,with,try,except,finally,def,class
set modeline
syntax on
" Closes the Omni-Completion tip window when a selection is
" made
autocmd CursorMovedI * if pumvisible() == 0|pclose|endif
autocmd InsertLeave * if pumvisible() == 0|pclose|endif