vim配置python IDE

1.文法高亮
为了能在Vim中支持Python文法需要用到插件python.vim,该插件默认位于<Vim安装目录>/<$VIMRUNTIME>/syntax/下,如果你在该路径下没有找到这个插件,需要到python.vim : Enhanced version of the python syntax highlighting script下载。然后为了能让Vim识别Python文法需要在vimrc中添加:
set filetype=pythonau BufNewFile,BufRead *.py,*.pyw setf python
2.缩进
在vimrc中添加如下缩进相关的代码:
set autoindent " same level indentset smartindent " next level indentset expandtab

set tabstop=4

set shiftwidth=4

set softtabstop=4

.树形目录
官网:http://www.vim.org/scripts/script.php?script_id=1658
"nerdtree
map <F3> :NERDTreeToggle<CR>

 

4.项目视图
官网:http://www.vim.org/scripts/script.php?script_id=273
ctags http://ctags.sourceforge.net/
"taglist
let Tlist_Ctags_Cmd = 'D:\python_tool\ctags58\ctags.exe' "注意下载ctags
let g:ctags_statusline=1
let generate_tags=1
let Tlist_Use_Horiz_Window=0
map <F4> : TlistToggle<cr>
let Tlist_Show_One_File=1
let Tlist_Use_Right_Window=1
let Tlist_Compact_Format=1
let Tlist_Exit_OnlyWindow=1
let Tlist_GainFocus_On_toggleOpen=1
let Tlist_File_Fold_Auto_Close=1

 

5.语法检查

官网:http://www.vim.org/scripts/script.php?script_id=2441
“pyflakes


6.帮助文档
"pydoc
let g:pydoc_cmd = 'D:\python_tool\pydoc.py'
用法
Pydoc <keyword> 例如 Pydoc re.compile
* PydocSearch <keyword> 在windows下有问题
*当光标在某个词上时,按下’K’


7.代码补全
官网:http://www.vim.org/scripts/script.php?script_id=850
"自动补全代码
"pydiction 1.2 python auto complete
filetype plugin on
let g:pydiction_location = 'D:\python_tool\complete-dict'
"defalut g:pydiction_menu_height == 15
"let g:pydiction_menu_height = 20

我的_vimrc文件:
set nocompatible "去掉讨厌的有关vi一致性模式,避免以前版本的一些bug和局限
set magic " 设置魔术
set ru "标尺信息
set ai
set sw=4 "Tab 宽度为4 个字符
set nu " 显示行号
set ts=4
set dy=lastline "显示最多行,不用@@
"以上是缩进相关
set backspace=indent,eol,start
colo lucius "配色方案
sy on
set go= "无菜单、工具栏
set nobackup "从不备份
set hlsearch "搜索逐字符高亮
set showmatch " 匹配括号高亮的时间(单位是十分之一秒)
"tab mappings
"自动补全
:inoremap ( ()<ESC>i
:inoremap ) <c-r>=ClosePair(')')<CR>
:inoremap < <><ESC>i
:inoremap > <c-r>=ClosePair('>')<CR>
:inoremap { {<CR>}<ESC>O
:inoremap } <c-r>=ClosePair('}')<CR>
:inoremap [ []<ESC>i
:inoremap ] <c-r>=ClosePair(']')<CR>
:inoremap " ""<ESC>i
:inoremap ' ''<ESC>i
function! ClosePair(char)
if getline('.')[col('.') - 1] == a:char
return "\<Right>"
else
return a:char
endif
endfunction
filetype plugin indent on

"自动补全代码
"pydiction 1.2 python auto complete
filetype plugin on
let g:pydiction_location = 'D:\python_tool\complete-dict'
"defalut g:pydiction_menu_height == 15
"let g:pydiction_menu_height = 20


execute pathogen#infect()

"pydoc
let g:pydoc_cmd = 'D:\python_tool\pydoc.py'

"jsbeautify的设置

nnoremap <leader>_ff :call g:Jsbeautify()<CR>


"taglist
let Tlist_Ctags_Cmd = 'D:\python_tool\ctags58\ctags.exe' "注意下载ctags
let g:ctags_statusline=1
let generate_tags=1
let Tlist_Use_Horiz_Window=0
map <F4> : TlistToggle<cr>
let Tlist_Show_One_File=1
let Tlist_Use_Right_Window=1
let Tlist_Compact_Format=1
let Tlist_Exit_OnlyWindow=1
let Tlist_GainFocus_On_toggleOpen=1
let Tlist_File_Fold_Auto_Close=1

"nerdtree
map <F3> :NERDTreeToggle<CR>


" 映射全选+复制 ctrl+a
map <C-A> ggVGY
map! <C-A> <Esc>ggVGY
map <F12> gg=G
" 选中状态下 Ctrl+c 复制
vmap <C-c> "+y

map <M-1> 1gt
map <M-2> 2gt
map <M-3> 3gt
map <M-4> 4gt
map <M-5> 5gt
map <M-6> 6gt
map <M-7> 7gt
map <M-8> 8gt
map <M-9> 9gt
map <M-t> :tabnew<CR>
map <M-w> :tabclose<CR>
map! <M-1> <esc>1gt
map! <M-2> <esc>2gt
map! <M-3> <esc>3gt
map! <M-4> <esc>4gt
map! <M-5> <esc>5gt
map! <M-6> <esc>6gt
map! <M-7> <esc>7gt
map! <M-8> <esc>8gt
map! <M-9> <esc>9gt
map! <M-t> <esc>:tabnew<CR>
map! <M-w> <esc>:tabclose<CR>

" Use CTRL-S for saving, also in Insert mode
noremap <C-S> :update<CR>
vnoremap <C-S> <C-C>:update<CR>
inoremap <C-S> <C-O>:update<CR>
"2006-09-13 如下:保存视图
au BufWinLeave *.ztx mkview
au BufWinEnter *.ztx silent loadview
au BufNewFile,BufRead *.tx1 setf tx1

posted @ 2013-07-25 17:16  wangshijun  阅读(871)  评论(0编辑  收藏  举报