Python開發(fā)如何在ubuntu 15.10 上配置vim
1,安裝vim,你可以使用ubuntu 自帶的apt-get 工具安裝。
apt-get install vim-gnome
2,安裝成功后,進(jìn)行配置
1>首先進(jìn)行自動(dòng)提示補(bǔ)全的配置(pydiction)
從官方上下載http://www.vim.org/scripts/script.php?script_id=850最新的即可,解壓縮后,進(jìn)入解壓縮后的目錄,執(zhí)行如下命令
# cp python_pydiction.vim /usr/share/vim/vim74/ftplugin # mkdir /usr/share/vim/vim74/pydiction # cp complete-dict pydiction.py /usr/share/vim/vim74/pydiction/ # vi ~/.vimrc
講解:
第一行 就是復(fù)制下載的文件 到/usr/share/vim/vim74/ftplugin
第二行 就是在/usr/share/vim/vim74/目錄下創(chuàng)建文件夾pydiction
第三行 復(fù)制 complete-dict pydiction.py 這兩個(gè)文件到
第四行 打開 .vimc配置文件
然后把下面的三行代碼復(fù)制到里面然后保存,應(yīng)該都會(huì)吧。
單擊Esc后,執(zhí)行:wq,保存
let g:pydiction_location = '/usr/share/vim/vim74/pydiction/complete-dict' let g:pydiction_menu_height = 20 autocmd FileType python set omnifunc=pythoncomplete#Complete
2>安裝python_fold自動(dòng)折疊插件從官方下載http://www.vim.org/scripts/script.php?script_id=515最新的插件,解壓縮后,進(jìn)入解壓縮后的目錄,執(zhí)行如下命令
# cp python_fold.vim /usr/share/vim/vim74/plugin/ # vi ~/.vimrc
講解:
第一行 就是復(fù)制下載的文件 到/usr/share/vim/vim74/plugin
第二行 打開 .vimc配置文件
然后把下面的一行代碼復(fù)制到里面
set foldmethod=indent
3> 安裝自動(dòng)高亮插件從官方上下載:http://www.vim.org/scripts/script.php?script_id=790,下載最新的插件,解壓縮后,進(jìn)入解壓縮后的目錄,執(zhí)行如下命令
mv /usr/share/vim/vim74/syntax/python.vim /usr/share/vim/vim74/syntax/python.vim_backup cp python.vim /usr/share/vim/vim74/syntax
講解:
第一行 就是將python.vim 備份
第二行 復(fù)制python.vim 到/usr/share/vim/vim74/syntax 目錄下
4> 生成 ctag 序列
進(jìn)入到 python 程序腳本(項(xiàng)目)所在的目錄,在該目錄下執(zhí)行:
ctags -R *
如果提示沒有安裝ctags,執(zhí)行apt-get install ctags即可。
生成一個(gè) ctags 文件,該文件記錄了程序/項(xiàng)目的函數(shù)、類等的分析序列記錄。有關(guān) ctag 的詳細(xì)用法請閱讀 ctag 的 manpage。
5>安裝taglist 插件
從官方上下載插件:http://www.vim.org/scripts/script.php?script_id=273 ,用最新的即可,解壓縮后,進(jìn)入解壓縮后的目錄,執(zhí)行如下命令。
# cp plugin/taglist.vim /usr/share/vim/vim74/plugin/ # cp doc/taglist.txt /usr/share/vim/vim74/doc/ # vi
執(zhí)行下面的命令
:helptags /usr/share/vim/vim74/doc
:help taglist.txt 第一行 生成 taglist 幫助文件列表 第二行 查看 taglist 幫助信息配置 vimrc, vi ~/.vimrc,在后面添加如下代碼
let Tlist_Show_One_File = 1 let Tlist_Exit_OnlyWindow = 1 let Tlist_Use_Right_Window = 1 let Tlist_Auto_Open=1 let Tlist_File_Fold_Auto_Close=1
講解:
第一行 不同時(shí)顯示多個(gè)文件的tag,只顯示當(dāng)前文件的。
第二行 如果 taglist 窗口是最后一個(gè)窗口,則退出 vim。
第三行 在右側(cè)窗口中顯示 taglist 窗口。
第四行 在啟動(dòng) vim 后,自動(dòng)打開 taglist 窗口。
第五行 只顯示當(dāng)前文件 tag,其它文件的tag折疊。
最后的配置結(jié)果截圖如下:

配置文件內(nèi)容如下:需要的可復(fù)制。
set tabstop=4 set softtabstop=4 set shiftwidth=4 set expandtab set autoindent set foldmethod=indent 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 autocmd FileType python set omnifunc=pythoncomplete#Complete let g:pydiction_location = '/usr/share/vim/vim74/pydiction/complete-dict' let g:pydiction_menu_height = 20 set foldmethod=indent
配置后,文件編輯結(jié)果如下:

相關(guān)文章
python調(diào)用百度通用翻譯API的方法實(shí)現(xiàn)
本文主要介紹了python調(diào)用百度通用翻譯API的方法實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2025-01-01
python中opencv K均值聚類的實(shí)現(xiàn)示例
本文主要介紹了python中opencv K均值聚類的實(shí)現(xiàn)示例,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2022-06-06
python+opencv實(shí)現(xiàn)論文插圖局部放大并拼接效果
在做圖像數(shù)據(jù)標(biāo)注時(shí),很難一次就做到精準(zhǔn)標(biāo)注,如果目標(biāo)比較小,即使微調(diào)也難以做到精準(zhǔn),所以就需要另外一個(gè)窗口對標(biāo)注區(qū)域進(jìn)行局部放大以方便微調(diào),這篇文章主要給大家介紹了關(guān)于python+opencv實(shí)現(xiàn)論文插圖局部放大并拼接效果的相關(guān)資料,需要的朋友可以參考下2021-10-10
python 實(shí)現(xiàn)兩個(gè)變量值進(jìn)行交換的n種操作
這篇文章主要介紹了python 實(shí)現(xiàn)兩個(gè)變量值進(jìn)行交換的n種操作,具有很好的參考價(jià)值,希望對大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2021-06-06

