Vim 调试脚本
Vimrc 中
" Debug map <F5> :call DebugRun()<cr> imap <F5> <Esc>:call DebugRun()<cr>
C:\Program Files\Vim\vimfiles\plugin\DebugRun.vim
" " debug c " 原来本想编译 c/c++ ,后来又加入了 html " if exists("loaded_DebugRun") finish endif let loaded_DebugRun = 1 function DebugRun() python <<EOF import vim import os vim.command(':w') filename = vim.current.buffer.name [filebasename , fileext] = os.path.splitext( os.path.basename(filename) ) defun = lambda cmd:vim.command('!'+cmd+' '+filebasename+fileext) if fileext == '.cpp' or fileext == '.c' : ''' import time import stat if ( not os.path.exists(filebasename+'.exe') ) or ( os.path.getmtime( filebasename+'.exe' ) < os.path.getmtime( filebasename+fileext ) ) : vim.command(':call CompileC()') ''' if os.path.exists( filebasename+'.exe' ): vim.command('!'+filebasename+'.exe') else : print 'Complie first , <F7> .' elif fileext == '.html' or fileext == '.htm' : import webbrowser webbrowser.open_new_tab(filename) elif fileext == '.java' : sym = 'applet' if sym in '\n'.join( vim.current.buffer[0:3] ) : if os.path.exists( filebasename+'.html' ): vim.command('!appletviewer %s' % (filebasename+'.html') ) else : print 'Complie first , <F7> .' elif os.path.exists(filebasename+'.class') : vim.command( '!java %s' % filebasename ) elif fileext == '.php' : defun('php') elif fileext == '.py' : defun('python') elif fileext == '.rb' : defun('ruby') elif fileext == '.scm' : defun('mzscheme -r') EOF endfunction "command! Compilec call CompileC() " nmap <silent> <Leader>tt :call AutoTpl()<CR> " command! <leader>NN call VimPlayer() " "if !hasmapto('<Plug>VimPlayer') " nmap <silent><unique> <Leader>pp <Plug>VimPlayer "endif "nnoremap <unique><script> <Plug>VimPlayer:VimPlayer<CR>