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

vim python自动补全功能

2016-10-18 21:41 393 查看
1. 安装完整的vim

# apt-get install vim-gnome

2. 安装ctags,ctags用于支持taglist,必需!

# apt-get install ctags

3. 安装taglist

#apt-get install vim-scripts

#apt-get install vim-addon-manager

// 貌似我在安装vim-scripts的时候,已经附带安装了vim-addon-manager

# vim-addons install taglist

4. 安装pydiction(实现代码补全)

#wget http://www.pythonclub.org/_media/python-basic/pydiction-1.2.zip
#unzip pydiction-1.2.zip

// ~/.vim/after/ftplugin和~/.vim/tools/pydiction/目录默认不存在,需要自行创建

#cp pydiction-1.2/python_pydiction.vim ~/.vim/after/ftplugin

#cp pydiction-1.2/complete-dict ~/.vim/tools/pydiction/complete-dict

5. 编辑配置文件

# vim ~/.vimrc

以下是配置文件的内容:

[html] view
plain copy

let Tlist_Auto_Highlight_Tag=1    

let Tlist_Auto_Open=1    

let Tlist_Auto_Update=1    

let Tlist_Display_Tag_Scope=1    

let Tlist_Exit_OnlyWindow=1    

let Tlist_Enable_Dold_Column=1    

let Tlist_File_Fold_Auto_Close=1    

let Tlist_Show_One_File=1    

let Tlist_Use_Right_Window=1    

let Tlist_Use_SingleClick=1    

nnoremap <silent> <F8> :TlistToggle<CR>  

     

filetype plugin on    

autocmd FileType python set omnifunc=pythoncomplete#Complete    

autocmd FileType javascrīpt set omnifunc=javascriptcomplete#CompleteJS    

autocmd FileType html set omnifunc=htmlcomplete#CompleteTags    

autocmd FileType css set omnifunc=csscomplete#CompleteCSS    

autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags    

autocmd FileType php set omnifunc=phpcomplete#CompletePHP    

autocmd FileType c set omnifunc=ccomplete#Complete    

     

     

let g:pydiction_location='~/.vim/tools/pydiction/complete-dict'    

set autoindent  

set tabstop=4    

set shiftwidth=4    

set expandtab    

set number  

其中,

filetype plugin on:表示开启插件。

let g:pydiction_location='~/.vim/tools/pydiction/complete-dict' : 写入你存放complete-dict的绝对路径。

参考:
http://www.350351.com/bianchengyuyan/Python/344419.html http://www.cnblogs.com/Bonker/p/4058728.html https://www.zhihu.com/question/20381207 http://blog.csdn.net/u010388829/article/details/41846235
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: