首页 > 代码库 > vim配置添加python

vim配置添加python

"   pydiction 补全提示+

"   pythoncomplete vim自带的python补全提示




"    pyflakes        Python代码检查+


" VimPdb 调试Python程序+

f2打断点116,,119

f3输入a,查看a的值

 执行到119

f12查看堆栈



vim配置

  1 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""  2 " Copycat: lulu  3 " Version: 3.3.3  4 " Install: 在linux和windows下无需改动配置文件的内容,对应配置文件夹是vim_3.3  5 "          在linux下在 ~/ 目录下,配置文件名改成 .vimrc,路径为 ~/.vimrc  6 "                          配置文件夹名改成 .vim,路径为 ~/.vim  7 "          在windows下在 $(vim)/ 目录下,配置文件名改成 _vimrc,路径为 Vim/_vimrc  8 "                              配置文件夹名改成 vimfiles,路径为 Vim/vimfiles  9 " Time:    2014.11.15 (增加ptyhon插件) 10 " Bug:       VimPdb 和 lookupfile 的F5冲突  11 " Modifty: 去掉了Minbuf和omnicppcomplete提示窗口and Tagbar放到左边 12 "           增加pydiction        补全提示 13 "           开启pythoncomplete    vim自带的python补全提示 14 "           增加VimPdb            调试Python程序 15 "           增加pyflakes            Python代码检查 16 " 17 " 18 "索引     19 "    ctags 20 "    cscope 21 " 22 "函数提示 23 "    echofunc(2.0) 24 "    taglist(4.5) 25 "    Tagbar(2.4.1)支持面向对象+ 26 " 27 "窗口 28 "    WinManager(2.3) 29 "    nerdtree(4.2) 30 "    MiniBufExplorer(6.3.2)--------------------------------------------------已剔除 31 " 32 "智能补全     33 "    supertab(2.0) 34 "    omnicppcomplete(0.41) 35 " 36 "其他 37 "    drawit(11)画图 38 "     conqueterm(2.2)vim中打开终端的功能+  39 "    csExplorer(7.0.1)提供列出配色列表的功+ 40 "   calendar.vim(2.5)提供日历的功能,并且可以记笔记+ 41 "   visincr(20)提供生成数列的功能+ 42 "   fencview(4.8)字符编码识别+ 43 "    visincr(20)提供生成数列的功能+  :SO % 后visincr.vba.gz会消失变成visincr.vba 44 "   cmdline completion(0.04)命令行模式的补全+  45 "     46 " 47 "项目管理插件 48 "    project(1.4.1)+ 49 "   grep.vim(1.9)工程内查找与替换+ 50 "    bufexplorer(7.3.1)打开历史文件列表以达到快速切换文件+ 51 "   lookupfile(1.8)文件查找+ 52 "   genutils(2.5)底层的lookupfile的功能支持+ 53 "    FuzzyFinder(4.2.2)缓冲器/文件/命令/标签/等浏览器的模糊匹配 + 54 "   l9(1.1)FuzzyFinder底层依耐+ 55 " 56 "c/c++ 辅助 57 "    c.vim(6.0)+ 58 "   stl.vim(0.1)stl语法高亮+ 59 "    stlrefvim(1.0)stl帮助 + 60 "   a.vim(2.18) .c, .cpp <-->.h快速切换+ 61 "   man.vim(内置)查看系统调用+ 62 "    cscope_vim.vim(cscope映射)+ 63 "    NERD_commenter(2.3.0)提供快速注释/反注释代码块的功能+ 64 "    checksyntax.vba(2.02)语法检查+ (跟lookupfile.vim的F5冲突了,把checksyntax.vimF5改成F6) 65 "     auto.vim(2.1)自动排版,可以少打很多空格---------------------------------------------以剔除 66 " 67 "python 插件 68 "    pydiction        补全提示+ 69 "    pythoncomplete    vim自带的python补全提示 70 "    VimPdb            调试Python程序+ 71 "    pyflakes        Python代码检查+ 72 " 73 " 74 "     + = 新增加的插件 75 " 76 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 77 " 文本格式和排版 78 " 79 set formatoptions=tcrqn     " 自动格式化 80 set autoindent             " 继承前一行的缩进方式,特别适用于多行注释 81 set smartindent         " 为C程序提供自动缩进 82 set cindent             " 使用C样式的缩进 83 set smarttab             " 在行和段开始处使用制表符 84 set tabstop=4             " 制表符为4 85 set softtabstop=4         " 统一缩进为4 86 set shiftwidth=4 87 "set noexpandtab         " 不要用空格代替制表符 88 "set nowrap             " 不要换行 89 set fileformats=unix,dos     " 自动识别UNIX格式和MS-DOS格式 90 set fileformat=mac 91  92  93 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 94 " 设置字符集(看情况具体选择) 95 " 96 "let &termencoding=&encoding 97 "set fileencodings=utf-8,gbk,ucs-bom,cp936 98 "set fileencoding=gb18030 99 "set fileencodings=utf-8,gb18030,utf-16,big5100 "set enc=utf-8101 "set fencs=utf-8,ucs-bom,shift-jis,gb18030,gbk,gb2312,cp936102 103 set fileencoding=gb2312104 105 106 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""107 " 搜索和匹配 108 "109 set showmatch             " 高亮显示匹配的括号110 set matchtime=5         " 匹配括号高亮的时间(单位是十分之一秒)111 set scrolloff=10          " 光标移动到buffer的顶部和底部时保持10行距离112 set hlsearch             " 高亮搜索113 "set nowrapscan         " 查找到文件头或文件尾时停止114 set incsearch             " 边输入边查找115 "set laststatus=2         " 总是显示状态行116 set ignorecase             " 在搜索的时候忽略大小写117 "set statusline=%F%m%r%h%w\[POS=%l,%v][%p%%]\%{strftime(\”%d/%m/%y\ -\ %H:%M\”)} 118                 " 我的状态行显示的内容(包括文件类型和解码)119 120 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""121 " 文件设置122 "123 set shortmess=atI         " 启动的时候不显示那个援助索马里儿童的提示`124 set report=0             " 通过使用: commands命令,告诉我们文件的哪一行被改变过125 set fillchars=vert:\ ,stl:\     " 在被分割的窗口间显示空白,便于阅读 ,stlnc:\(加了这个wm分割兰有\\\\\\\\\\\\\)126 set mouse=a             " 可以在buffer的任何地方使用鼠标(类似office中在工作区双击鼠标定位)127 set selection=exclusive128 set selectmode=mouse,key129 130 131 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""132 " 一般设置133 "134 set viminfo+=!             " 保存全局变量135 set history=300         " history文件中需要记录的行数136 set nocompatible         " 不要使用vi的键盘模式,而是vim自己的137 set foldmethod=syntax138 set foldlevel=100          " 启动vim时不要自动折叠代码139 set nu140 set fileencodings=utf-8,gbk141 set ruler142 set showmatch             " 高亮显示匹配的括号 143 filetype on             " 侦测文件类型 144 set nobackup             " 不要备份文件(根据自己需要取舍) 145 "set backup146 syntax enable147 syntax on             " 语法高亮 148 set magic             " 设置正表达式149 set backspace=indent,eol,start     " 这指明在插入模式下在哪里允许 <BS> 删除光标前面的字符。150                 " 逗号分隔的三个值分别指:行首的空白字符,换行符和插入模式开始处之前的字符。151 set showcmd             " 在 Vim 窗口右下角,标尺的右边显示未完成的命令152 set noerrorbells         " 不让vim发出讨厌的滴滴声153 set novisualbell         " 不要闪烁154 "set vb t_vb=             " 没发出声音和闪烁 (在windows下写在配置文件无效必须用命令行输入 或者 重新:source vimrc才有效)155 " :inoremap ( ()<ESC>i156 " :inoremap { {<CR>}<ESC>O157 " :inoremap [ []<ESC>i158 " :inoremap " ""<ESC>i159 " :inoremap ‘ ‘‘<ESC>i160 161 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""162 " 编译链接163 "164 nmap<Leader>m :wa<CR>:make<CR>:cw<CR><CR>165 " 分解说明下,<Leader>m设定快捷键为;m(;由<Leader>指定),:wa<CR>保持所有打开的文档,166 " :make<CR>执行make命令,:cw<CR>显示quickfix(如果有编译错误或警告时),167 " 最后的<CR>消除make命令执行完成屏幕上“PressENTER or type command to continue”的输入等待提示信息。168 169 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""170 " GUI171 "172 if has("gui_running")             " 如果是图形界面   173     set guioptions=m         " 关闭菜单栏174     set guioptions=t         " 关闭工具栏175 "    set guioptions=L         " 启动左边的滚动条176 "    set guioptions+=r         " 启动右边的滚动条177 "    set guioptions+=b         " 启动下边的滚动条178     set clipboard+=unnamed         " 共享剪贴板179     if has("win32")180            colorscheme torte     " torte配色方案181            "set guifont=Consolas:h12 " 字体和大小182            "set guifont=Consolas:h11 " 字体和大小183            set guifont=Consolas:h10 " 字体和大小184            set guifont=Consolas:h9 " 字体和大小185            set guifont=Consolas:h8 " 字体和大小186            map <F11> <Esc>:call libcallnr("gvimfullscreen.dll", "ToggleFullScreen", 0)<CR>    " 非插入模式下F11全屏187            imap <F11> <Esc>:call libcallnr("gvimfullscreen.dll", "ToggleFullScreen", 0)<CR>   " 插入模式下F11全屏188     endif189 endif 190 191 if has(win32)192 endif193 194 195 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""196 " taglist 197 "198 let Tlist_Use_Right_Window = 1         " 在左侧显示窗口199 let Tlist_Compart_Format = 1         " 压缩方式200 let Tlist_Exist_OnlyWindow = 1         " 如果只有一个buffer,kill窗口也kill掉buffer201 let Tlist_File_Fold_Auto_Close = 0     " 不要关闭其他文件的tags202 let Tlist_Enable_Fold_Column = 0     " 不要显示折叠树 (鼠标可以点开)203 let Tlist_WinWidth = 25                 " taglist窗口宽度204 nmap <silent> <leader>tl :Tlist<cr>205 if has("win32")             206     let Tlist_Ctags_Cmd =    ctags "windows下必须空3个字符,否则解析成gs 207 else 208     let Tlist_Ctags_Cmd = /usr/bin/ctags209 endif210 211 "标签列表窗口显示或隐藏不影响整个gvim窗口大小212 let Tlist_Inc_Winwidth = 0213 "设置tablist插件只显示当前编辑文件的tag内容,而非当前所有打开文件的tag内容214 let Tlist_Show_One_File=1215 216 217 218 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""219 " netrw220 "221 let NERDTreeWinPos = right222 let g:netrw_winsize = 35223 nmap <silent> <leader>fe :Sexplore!<cr>224 225 226 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""227 " winmanager 228 "229 let g:winManagerWindowLayout=NERDTree|BufExplorer230 "let g:winManagerWindowLayout = ‘FileExplorer|TagList‘231 "let g:winManagerWindowLayout = ‘FileExplorer‘232 let g:winManagerWidth = 25233 let g:defaultExplorer = 0234 nmap wm :WMToggle<cr>235 nmap <C-W><C-F> :FirstExplorerWindow<cr>236 nmap <C-W><C-B> :BottomExplorerWindow<cr>237 autocmd BufWinEnter \[Buf\ List\] setl nonumber238 239 240 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""241 " omnicppcomplete242 "243 set nocp244 set completeopt=menu "去掉提示窗口"245 filetype plugin on246 let OmniCpp_DefaultNamespaces = ["std"]     "下面的设置用于当用户预先声明namespace时也能自动补全代码(如使用using std::string) 247 let OmniCpp_NamespaceSearch = 1248 let OmniCpp_GlobalScopeSearch = 1249 let OmniCpp_ShowAccess = 1 250 let OmniCpp_ShowPrototypeInAbbr = 1 " 显示函数参数列表 251 let OmniCpp_MayCompleteDot = 1   " 输入 .  后自动补全252 let OmniCpp_MayCompleteArrow = 1 " 输入 -> 后自动补全 253 let OmniCpp_MayCompleteScope = 1 " 输入 :: 后自动补全 254 let OmniCpp_DefaultNamespaces = ["std", "_GLIBCXX_STD"]255 256 filetype plugin indent on257 set completeopt=longest,menu258 set wildmenu259 autocmd FileType python set omnifunc=pythoncomplete#Complete260 261 if has("win32")                 " 设置代码提示窗口的颜色(默认为粉红色) 262 "    highlight Pmenu ctermbg=13 guibg=LightGray 263 "    highlight PmenuSel ctermbg=7 guibg=DarkBlue guifg=White 264     highlight Pmenu ctermbg=7 guibg=DarkBlue guifg=White265 "       highlight PmenuSbar ctermbg=7 guibg=DarkGray 266 "    highlight PmenuThumb guibg=Black267 endif268 269 270 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""271 " minibufexpl   272 "273 let g:miniBufExplMapWindowNavVim = 1 274 let g:miniBufExplMapWindowNavArrows = 1 275 let g:miniBufExplMapCTabSwitchBufs = 1 276 let g:miniBufExplModSelTarget = 1 277 "let g:miniBufExplorerMoreThanOne=1         "自动打开278 279 280 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""281 " cscope282 "283 if has("cscope")284     set csto=0285     set cst286     set nocsverb287     if filereadable("cscope.out")        " add any database in current directory     288         cs add cscope.out289     elseif $CSCOPE_DB != ""         " else add database pointed to by environment        290         cs add $CSCOPE_DB291     endif292     set csverb                 " 这个必须放在后面,不然windows上找不到cscope.out293 endif294 295 nmap <C-\>s :cs find s <C-R>=expand("<cword>")<CR><CR> :cw<CR>296 nmap <C-\>g :cs find g <C-R>=expand("<cword>")<CR><CR> :cw<CR>297 nmap <C-\>c :cs find c <C-R>=expand("<cword>")<CR><CR> :cw<CR>298 nmap <C-\>t :cs find t <C-R>=expand("<cword>")<CR><CR> :cw<CR>299 nmap <C-\>e :cs find e <C-R>=expand("<cword>")<CR><CR> :cw<CR>300 nmap <C-\>f :cs find f <C-R>=expand("<cfile>")<CR><CR> :cw<CR>301 nmap <C-\>i :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR> :cw<CR>302 nmap <C-\>d :cs find d <C-R>=expand("<cword>")<CR><CR> :cw<CR>303 "nmap <C-_>s :cs find s <C-R>=expand("<cword>")<CR><CR>304 "nmap <C-_>g :cs find g <C-R>=expand("<cword>")<CR><CR>305 "nmap <C-_>c :cs find c <C-R>=expand("<cword>")<CR><CR>306 "nmap <C-_>t :cs find t <C-R>=expand("<cword>")<CR><CR>307 "nmap <C-_>e :cs find e <C-R>=expand("<cword>")<CR><CR>308 "nmap <C-_>f :cs find f <C-R>=expand("<cfile>")<CR><CR>309 "nmap <C-_>i :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR>310 "nmap <C-_>d :cs find d <C-R>=expand("<cword>")<CR><CR>  311 312 " Using ‘CTRL-spacebar‘ then a search type makes the vim window313 " split horizontally, with search result displayed in314 " the new window.  315 nmap <C-Space>s :scs find s <C-R>=expand("<cword>")<CR><CR>316 nmap <C-Space>g :scs find g <C-R>=expand("<cword>")<CR><CR>317 nmap <C-Space>c :scs find c <C-R>=expand("<cword>")<CR><CR>318 nmap <C-Space>t :scs find t <C-R>=expand("<cword>")<CR><CR>319 nmap <C-Space>e :scs find e <C-R>=expand("<cword>")<CR><CR>320 nmap <C-Space>f :scs find f <C-R>=expand("<cfile>")<CR><CR>321 nmap <C-Space>i :scs find i ^<C-R>=expand("<cfile>")<CR>$<CR>322 nmap <C-Space>d :scs find d <C-R>=expand("<cword>")<CR><CR>  323 324 " Hitting CTRL-space *twice* before the search type does a vertical325 " split instead of a horizontal one  326 nmap <C-Space><C-Space>s327     \:vert scs find s <C-R>=expand("<cword>")<CR><CR>328 nmap <C-Space><C-Space>g329     \:vert scs find g <C-R>=expand("<cword>")<CR><CR>330 nmap <C-Space><C-Space>c331     \:vert scs find c <C-R>=expand("<cword>")<CR><CR>332 nmap <C-Space><C-Space>t333     \:vert scs find t <C-R>=expand("<cword>")<CR><CR>334 nmap <C-Space><C-Space>e335     \:vert scs find e <C-R>=expand("<cword>")<CR><CR>336 nmap <C-Space><C-Space>i337     \:vert scs find i ^<C-R>=expand("<cfile>")<CR>$<CR>338 nmap <C-Space><C-Space>d339     \:vert scs find d <C-R>=expand("<cword>")<CR><CR>  340 341 342 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""343 " a.vim344 " A few of quick commands to swtich between source files and header files quickly. 345 346 " :A switches to the header file corresponding to the current file being edited (or vise versa) 347 " :AS splits and switches 348 " :AV vertical splits and switches 349 " :AT new tab and switches 350 " :AN cycles through matches 351 " :IH switches to file under cursor 352 " :IHS splits and switches 353 " :IHV vertical splits and switches 354 " :IHT new tab and switches 355 " :IHN cycles through matches 356 " <Leader>ih switches to file under cursor 357 " <Leader>is switches to the alternate file of file under cursor (e.g. on  <foo.h> switches to foo.cpp) 358 " <Leader>ihn cycles through matches 359 "360 " E.g. if you are editing foo.c and need to edit foo.h 361 "      simply execute :A and you will be editting foo.h,  362 "      to switch back to foo.c execute :A again. 363 "364 " Can be configured to support a variety of languages. Builtin support for C, C++ and ADA95365 "366 367 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""368 " lookupfile.vim 插件设置369 "370 let g:LookupFile_MinPatLength = 2               "最少输入2个字符才开始查找371 let g:LookupFile_PreserveLastPattern = 0        "不保存上次查找的字符串372 let g:LookupFile_PreservePatternHistory = 1     "保存查找历史373 let g:LookupFile_AlwaysAcceptFirst = 1          "回车打开第一个匹配项目374 let g:LookupFile_AllowNewFiles = 0              "不允许创建不存在的文件375 let g:LookupFile_SortMethod = ""                "关闭对搜索结果的字母排序376 "if filereadable("/home/ganquan/linux-2.6.34-rc4/filenametags")                "设置tag文件的名字377 "let g:LookupFile_TagExpr =‘"/home/ganquan/linux-2.6.34-rc4/filenametags"378 "endif379 380 381 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""382 " lookupfile.vim 插件设置383 "384 let g:tagbar_left = 1     "Tagbar放到左边385 386 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""387 " Pydiction388 "389 let g:pydiction_location = D:\Vim\vimfiles\ftplugin\complete-dict390 391 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""392 " pythoncomplete                    393 "394 "按下 Ctrl+x, Ctrl+o, 就能看到提示列表框,以及对应的 docstring.395 "      Ctrl+n, Ctrl+p 来上下选择396 filetype plugin on397 autocmd FileType python set omnifunc=pythoncomplete#Complete 398 399 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""400 " VimPdb401 "402 "                        vimfiles readme.txt403 "4. Key Bindings404 "-----------------405 "406 "- F5 - Start/continue debug session of current file.407 "- Ctrl-F5 - Start debugging and do not pause at first line408 "- Ctrl-Shift-F5 - Start debugging with a given list of parameters.409 "- Shift-F5 - Stop the current debug session.410 "- Ctrl-Alt-Shift-F5 - Restart the current debug session.411 "412 "- F2 - Toggle breakpoint.413 "- Ctrl-F2 - Toggle conditional breakpoint414 "- Shift-F2 - Toggle temporary breakpoint415 "- Ctrl-Shift-F2 - Clear all breakpoints in current file416 "- Ctrl-Alt-Shift-F2 - Clear all breakpoints in all files417 "- F11 - Print condition of conditional breakpoint under the cursor418 "419 "- F7 - Step into420 "- F8 - Step over421 "- Ctrl-F8 - Continue running until reaching a return from function422 "423 "- F6 - Move cursor to currently debugged line.424 "- Ctrl-F6 - Change current debugged line to where the cursor is currently placed.425 "426 "- F9 - Move up in stack frame.427 "- F10 - Move down in stack frame.428 "429 "- F12 - Print stack trace430 "431 "- F3 - Eval a given expression (in the current debug context)432 "- Ctrl-F3 - Exec a given statement (in the current debug context)433 "434 "- F4 - Eval the current word under the cursor (in the current debug context)435 "- Ctrl-F4 - Eval the current WORD under the cursor (in the current debug context)436 "437 "- <Leader>s - Save current debug session breakpoints to a file.438 "- <Leader>l - Load saved breakpoints from a file.439 "440 "5. Customizing VimPdb441 "-----------------------442 "443 "VimPdb.vim contains several options which allow the user to customize it:444 "445 "- stack_entry_format: the format used when printing the stack trace (using F12). Possible format keyword arguments:446 "    * dir - the directory of the debugged file.447 "    * filename - the filename of the debugged file.448 "    * line - the current line number.449 "    * function - the current function name.450 "    * args - the arguments passed to the current function.451 "    * return_value - the return value from the function.452 "    * source_line - the source code of the current line.453 "- stack_entries_joiner: when there‘s more than one line of stack trace, this string is used to join the lines.454 "- stack_entry_prefix: each stack trace entry line has this as its prefix.455 "- current_stack_entry_prefix: the current stack trace entry line is prefixed with this string.456 "457 "- auto_load_breakpoints_file: when this is set to 1, VimPdb will look for a saved breakpoints458 "  file (default_breakpoints_filename) in the current directory when loading a new debug session.459 "- auto_save_breakpoints_file: when this is set to 1, VimPdb will save all current session breakpoints into a460 "  file (default_breakpoints_filename) when exiting Vim.461 "- default_breakpoints_filename: the filename used when auto_load_breakpoints_file/auto_saved_breakpoints_file are set.462 "463 "The following highlighting groups can be changed as well:464 "- PdbCurrentLine: the currently debugged line.465 "- PdbBreakpoint: a "regular" breakpoint.466 "- PdbConditionalBreakpoint: a conditional breakpoint.467 "- PdbTemporaryBreakpoint: a temporary breakpoint.468 "469 "And of course, default key bindings can be modified.470 "471 472 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""473 " VimPdb474 "475 "        :cc,即可进行代码检查476 "477 "pyflakes-vim uses the output from PyFlakes to highlight errors in your code.478 "To locate errors quickly, use quickfix_ commands like :cc.479 "480 "

 



vim配置添加python