下载各种插件
首先去下载Python相关插件plugin:
1, 提供代码折叠功能
2, 提供查看文件折叠/展开列表功能
3, 提供快速代码注释功能
4, 提供源代码结构及函数,变量列表
5, 提供Tab补全代码功能
配置vimrc文件
:scriptnames 调出所有vim脚本
:e $VIM/_vimrc 打开vim配置文件。然后就像一般文本操作写下自定义的Vim配置
1,对python_fold的设置,(用法:zn, zc, zo
有 6 种方法来选定折叠:
manual 手工定义折叠
indent 更多的缩进表示更高级别的折叠
expr 用表达式来定义折叠
syntax 用语法高亮来定义折叠
diff 对没有更改的文本进行折叠
marker 对文中的标志折叠
-
set foldmethod=indent ''设置折叠方式
2,对NERD_tree的设置,假设绑定到F2
3,不需要配置,直接扔进Plugin文件夹内即可。(用法:\x ,支持单行,块
4,对tagList的设置,绑定到F3(需要安装ctags,并设置环境变量PATH)
-
"进行Tlist的设置
-
filetype on
-
let Tlist_Show_Menu = 1
-
"TlistUpdate可以更新tags
-
map :silent! Tlist "按下F3就可以呼出Taglist
-
let Tlist_Ctags_Cmd='ctags' "因为我们放在环境变量里,所以可以直接执行
-
let Tlist_Use_Right_Window=0 "让窗口显示在右边,0的话就是显示在左边
-
let Tlist_Show_One_File=1 "让taglist可以同时展示多个文件的函数列表,如果想只有1个,设置为1
-
let Tlist_File_Fold_Auto_Close=1 "非当前文件,函数列表折叠隐藏
-
let Tlist_Exit_OnlyWindow=1 "当taglist是最后一个分割窗口时,自动退出vim
-
let Tlist_Process_File_Always=0 "是否一直处理tags.1:处理;0:不处理
-
let Tlist_Inc_Winwidth=
5,配置Pydiction自动tab代码补全
把python_pydiction.vim文件拷贝到../ftplugin中
把complete-dict拷贝到../tools/pydiction中
-
filetype plugin on
-
let g:pydiction_location = 'C:\Program Files\Vim\vim73\tools\pydiction\complete-dict'
-
let g:pydiction_menu_height = 20
6,配置Python解释器,绑定到F5运行,F6编译
-
autocmd BufRead *.py set makeprg=python\ -c\ \"import\ py_compile,sys;\ sys.stderr=sys.stdout;\ py_compile.compile(r'%')\"
-
autocmd BufRead *.py set efm=%C\ %.%#,%A\ \ File\ \"%f\"\\,\ line\ %l%.%#,%Z%[%^\ ]%\\@=%m
-
autocmd BufRead *.py nmap :!python %
-
autocmd BufRead *.py nmap :make
-
autocmd BufRead *.py copen "如果是py文件,则同时打开编译信息窗口
最后放出vimrc当前的配置
-
set nocompatible
-
set number
-
syntax enable
-
syntax on "打开高亮
-
colorscheme desert
-
set nocompatible "不要vim模仿vi模式
-
set foldmethod=indent "设置折叠
-
source $VIMRUNTIME/vimrc_example.vim
-
source $VIMRUNTIME/mswin.vim
-
behave mswin
-
-
-
set diffexpr=MyDiff()
-
function MyDiff()
-
let opt = '-a --binary '
-
if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
-
if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
-
let arg1 = v:fname_in
-
if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif
-
let arg2 = v:fname_new
-
if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif
-
let arg3 = v:fname_out
-
if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif
-
let eq = ''
-
if $VIMRUNTIME =~ ' '
-
if &sh =~ '\
-
let cmd = '""' . $VIMRUNTIME . '\diff"'
-
let eq = '"'
-
else
-
let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"'
-
endif
-
else
-
let cmd = $VIMRUNTIME . '\diff'
-
endif
-
silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3 . eq
-
endfunction
-
-
"
-
if(has("win32") || has("win95") || has("win64") || has("win16")) "判定当前操作系统类型
-
let g:iswindows=1
-
else
-
let g:iswindows=0
-
endif
-
autocmd BufEnter * lcd %:p:h
-
-
if has("autocmd")
-
filetype plugin indent on "根据文件进行缩进
-
augroup vimrcEx
-
au!
-
autocmd FileType text setlocal textwidth=78
-
autocmd BufReadPost *
-
\ if line("'\"") > 1 && line("'\"") <= line("$") |
-
\ exe "normal! g`\"" |
-
\ endif
-
augroup END
-
else
-
set autoindent " always set autoindenting on
-
endif " has("autocmd")
-
set tabstop=4 "让一个tab等于4个空格
-
set vb t_vb=
-
set nowrap "不自动换行
-
set hlsearch "高亮显示结果
-
set incsearch "在输入要搜索的文字时,vim会实时匹配
-
set backspace=indent,eol,start whichwrap+=<,>,[,] "允许退格键的def使用
-
if(g:iswindows==1) "允许鼠标的使用
-
"防止linux终端下无法拷贝
-
if has('mouse')
-
set mouse=a
-
endif
-
au GUIEnter * simalt ~x
-
endif
-
-
"定制GUI界面
-
set go= "无菜单、工具栏"
-
-
"配置Python的编译&运行(F5运行脚本,F6编译脚本
-
autocmd BufRead *.py set makeprg=python\ -c\ \"import\ py_compile,sys;\ sys.stderr=sys.stdout;\ py_compile.compile(r'%')\"
-
autocmd BufRead *.py set efm=%C\ %.%#,%A\ \ File\ \"%f\"\\,\ line\ %l%.%#,%Z%[%^\ ]%\\@=%m
-
autocmd BufRead *.py nmap :!python %
-
autocmd BufRead *.py nmap :make
-
autocmd BufRead *.py copen "如果是py文件,则同时打开编译信息窗口
-
-
"NERDTree,提供查看文件折叠/展开列表功能
-
nmap :NERDTreeToggle
-
"imap :NERDTreeToggle
-
-
"进行Tlist的设置
-
filetype on
-
let Tlist_Show_Menu = 1
-
"TlistUpdate可以更新tags
-
map :silent! Tlist "按下F3就可以呼出Taglist
-
let Tlist_Ctags_Cmd='ctags' "因为我们放在环境变量里,所以可以直接执行
-
let Tlist_Use_Right_Window=0 "让窗口显示在右边,0的话就是显示在左边
-
let Tlist_Show_One_File=1 "让taglist可以同时展示多个文件的函数列表,如果想只有1个,设置为1
-
let Tlist_File_Fold_Auto_Close=1 "非当前文件,函数列表折叠隐藏
-
let Tlist_Exit_OnlyWindow=1 "当taglist是最后一个分割窗口时,自动退出vim
-
let Tlist_Process_File_Always=0 "是否一直处理tags.1:处理;0:不处理
-
let Tlist_Inc_Winwidth=0
-
"set tags=C:\Program Files\Vim\vim73\Tags "设置tags文件路径
-
-
-
map :call Do_CsTag()
-
nmap s :cs find s =expand(""):copen
-
nmap g :cs find g =expand("")
-
nmap c :cs find c =expand(""):copen
-
nmap t :cs find t =expand(""):copen
-
nmap e :cs find e =expand(""):copen
-
nmap f :cs find f =expand(""):copen
-
nmap i :cs find i ^=expand("")$:copen
-
nmap d :cs find d =expand(""):copen
-
function Do_CsTag()
-
let dir = getcwd()
-
if filereadable("tags")
-
if(g:iswindows==1)
-
let tagsdeleted=delete(dir."\\"."tags")
-
else
-
let tagsdeleted=delete("./"."tags")
-
endif
-
if(tagsdeleted!=0)
-
echohl WarningMsg | echo "Fail to do tags! I cannot delete the tags" | echohl None
-
return
-
endif
-
endif
-
if has("cscope")
-
silent! execute "cs kill -1"
-
endif
-
if filereadable("cscope.files")
-
if(g:iswindows==1)
-
let csfilesdeleted=delete(dir."\\"."cscope.files")
-
else
-
let csfilesdeleted=delete("./"."cscope.files")
-
endif
-
if(csfilesdeleted!=0)
-
echohl WarningMsg | echo "Fail to do cscope! I cannot delete the cscope.files" | echohl None
-
return
-
endif
-
endif
-
if filereadable("cscope.out")
-
if(g:iswindows==1)
-
let csoutdeleted=delete(dir."\\"."cscope.out")
-
else
-
let csoutdeleted=delete("./"."cscope.out")
-
endif
-
if(csoutdeleted!=0)
-
echohl WarningMsg | echo "Fail to do cscope! I cannot delete the cscope.out" | echohl None
-
return
-
endif
-
endif
-
if(executable('ctags'))
-
"silent! execute "!ctags -R --c-types=+p --fields=+S *"
-
silent! execute "!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q ."
-
endif
-
if(executable('cscope') && has("cscope") )
-
if(g:iswindows!=1)
-
silent! execute "!find . -name '*.h' -o -name '*.c' -o -name '*.cpp' -o -name '*.java' -o -name '*.cs' > cscope.files"
-
else
-
silent! execute "!dir /s/b *.c,*.cpp,*.h,*.java,*.cs >> cscope.files"
-
endif
-
silent! execute "!cscope -b"
-
execute "normal :"
-
if filereadable("cscope.out")
-
execute "cs add cscope.out"
-
endif
-
endif
-
endfunction
-
-
"对NERD_commenter的设置
-
"let NERDShutUp=1
-
-
" 使用F8打开
-
"nnoremap :TlistToggle
-
-
"设置文件浏览器窗口显示方式
-
"通过WinManager插件来将TagList窗口和netrw窗口整合起来
-
let g:winManagerWindowLayout='FileExplorer|TagList'
-
nmap wm :WMToggle
-
-
"设置PythonDict用Tab自动补全功能
-
filetype plugin on
-
let g:pydiction_location = 'C:\Program Files\Vim\vim73\tools\pydiction\complete-dict'
-
let g:pydiction_menu_height = 20
基本上以上的配置可以跑python的脚本了。
OK,Let's enjoy it~
阅读(3734) | 评论(0) | 转发(0) |