天天看點

VIM 配置Python開發環境 Taglist + Pydiction+ Highlight+Python_fold+NERD_tree+ autocomplete

VIM 配置Python開發環境 Taglist + Pydiction+Hightlight+Python_fold + NERD_TREE+.....

Luo weifeng 2011-7-16

1.      安裝完整的VIM

#apt-get install vim-gnome

2.      安裝Ctags

#apt-get install ctags

3.      安裝TagList

#apt-get install vim-scripts

#apt-get install 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 #cp pydiction-1.2/ python_pydiction.vim   ~/.vim/after/ftplugin #cp pydiction-1.2/complete-dict       ~/.vim/tools/pydiction/complete-dict 5.    編輯配置檔案 #vim ~/.vimrc

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 tabstop=4
set shiftwidth=4
set expandtab
set number
           

6.  享用吧

使用F8打開或關閉taglist視窗。 C-w w在taglist與code之間切換。  示例: 在code視窗定義幾個函數。使用:w 儲存。使用 C-w w切換到taglist視窗,輸入u 更新taglist清單。使用 j k或者up down鍵定位到特定tag上,使用t 定位到code裡邊tag定義的地方并且切換光标到此,使用p定位到code定義tag的地方,光标不切換回去。 使用tab補全标準庫或函數或關鍵詞,使用C-N補全自定義的變量等。tab會被替換成4個空格。

有圖有真相:

VIM 配置Python開發環境 Taglist + Pydiction+ Highlight+Python_fold+NERD_tree+ autocomplete

附加:highlight

http://www.vim.org/scripts/script.php?script_id=1599Line mode 

<C-h><C-h>   Highlight current line 

<C-h><C-a>   Advance color for next line highlight 

<C-h><C-r>   Clear last line highlight 

Pattern mode 

<C-h><C-w>   Highlight word under cursor (whole word match) 

<C-h><C-l>    Highlight all lines having word under cursor (whole word match) 

<C-h><C-f>    Highlight word under cursor (partial word match) 

<C-h><C-k>   Highlight all lines having word under cursor (partial word match) 

<C-h><C-s>   Highlight last search pattern 

<C-h><C-j>    Highlight all lines having last search pattern 

<C-h><C-d>   Clear last pattern highlight 

<C-h><C-n>   Clear all highlights 

All above commands work in both normal & insert modes. 

<C-h><C-h> also works in visual mode. (Select desired lines & hit <C-h><C-h>) 

python_fold自動折疊

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

zo 展開 

zc 收起 

zn 全部展開 

zN 全部折疊

NERD_TREE 目錄樹(強烈推薦)

安裝方法如下:

1.下載下傳插件檔案

http://www.vim.org/scripts/script.php?script_id=1658

解壓檔案到~/.vim/目錄下,如果沒有此目錄,則要自己建立。

2.添加配置檔案

在~/.vimrc 或 /etc/vim/vimrc檔案裡添加如下配置

“”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"

” F7 NERDTree

“”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"

map <F7> :NERDTreeToggle<CR>

imap <F7> <ESC>:NERDTreeToggle<CR>

則在VIM裡按下F7就可打開關閉目錄樹。具體操作指令請檢視插件doc目錄下的幫助檔案。

Auto Complete 這個比較霸氣

http://www.vim.org/scripts/script.php?script_id=1879

minibuffer

http://www.vim.org/scripts/script.php?script_id=159