Ⅰ. 插件描述
Vim plugin for debugging Ruby applications (using ruby-debug-ide gem)Ⅱ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'astashov/vim-ruby-debugger'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'astashov/vim-ruby-debugger'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'astashov/vim-ruby-debugger'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/astashov/vim-ruby-debugger
Ⅳ. 文档说明
# Disclaimer #
This is a new version of the plugin, which uses debugger-xml gem, and works only with Ruby >= 1.9. If you want to use ruby-debug-ide gem and/or Ruby <= 1.8.7, you should check 'v1.0' branch (http://github.com/astashov/vim-ruby-debugger/tree/v1.0)
Description
This Vim plugin implements interactive Ruby debugger in Vim.
This version of the plugin works only with Ruby >= 1.9. It uses debugger-xml under the hood, which is just a XML/IDE extension for the debugger gem, which supports Ruby 1.9.2 and 1.9.3 out-of-the-box, but doesn't support Ruby <= 1.8.7.
Features
- It can debug any Ruby application (Rails, by default), debugger-xml gem
- The debugger looks like in any IDE - you can go through the code, watch variables, breakpoints in a separate window, set and remove breakpoints.
- It supports execution of commands in the context of stopped line. E.g., you can execute ':RdbEval User.all' in the Vim command line and it will display the results like usual echo Vim command.
Requirements
Vim >= 7.0, compiled with +signs, +clientserver and +ruby. You can verify it by VIM command:
:echo has("signs") && has("clientserver") && has("ruby") && v:version > 700
It should show result '1'.- debugger-xml gem.
For OS X:
The vim that ships with OS X does not use ruby, nor does it support --servername, so MacVim must be used. Make sure that both MacVim, and mvim are installed. If they are not, you can use homebrew (http://mxcl.github.com/homebrew/):brew install macvim
This will install MacVim, along with the mvim command line utility.
Installation
Clone the repo
git clone git://github.com/astashov/vim-ruby-debugger.gitor just download the archive from here:
http://github.com/astashov/vim-ruby-debugger/tarball/masterYou will get the 'vim-ruby-debugger' dir with the plugin.
- Copy contents of the 'vim-ruby-debugger' dir to your ~/.vim/ (or to ~/.vim/bundle/vim-ruby-debugger if you use pathogen).
Generate the local tags file
:helptags ~/.vim/docNow, you can use
:help ruby-debuggerto get help for the ruby-debugger plugin.
If using MacVim:
Modify your ~/.vimrc to add the following line:
let g:ruby_debugger_progname = 'mvim'
Windows is not supported, sorry, Windows users.
Using
- Run Vim. If you use gvim/mvim, it will automatically start the server, but if you use vim, you need to set
servername explicitly, e.g., vim --servername VIM Go to the directory with some your Rails application.
:cd ~/projects/railsRun Server with Debugger:
:RdebuggerIt will run debugger-xml's rdebug-vim executable, create a UNIX socket in tmp directory,
and connect to debugger-xml through it.- Set a breakpoint somewhere by <Leader>b (e.g., 'b'). You should see 'xx' symbol at current line.
- Open a page with the breakpoint in a browser. Vim should automatically set the current line to the breakpoint.
After this, you can use commands:
<Leader>b - set breakpoint at current line <Leader>v - open/close window with variables. You can expand/collapse variables by 'o' in normal mode or left-mouse double-click <Leader>n - step over <Leader>s - step into <Leader>c - continueYou may find useful to override default shortcut commands by F5-F8 shortcuts. Add these to your .vimrc:
map <F7> :call g:RubyDebugger.step()<CR> map <F5> :call g:RubyDebugger.next()<CR> map <F8> :call g:RubyDebugger.continue()<CR>
Testing
If you want to run tests, replace in /autoload directory ruby_debugger.vim to ruby_debugger.vim from additionals/autoload directory.
And then, in command mode execute
:call g:TU.run()
Screenshot

Thanks
Special thanks to tpope (for rails.vim) and Marty Grenfell (for NERDTree), mostly, I learn Vim Scripting from their projects.