debugger style breakpoints with Pry in Vim

Right now, when I want a breakpoint in vim or Sublime Text, I drop a line like the following into the code:

binding.pry if Rails.env.test?

Pry (and its associated plugins) provide a nice environment in which to do interactive Ruby debugging from the command line.

However, adding actual code to my projects to create each breakpoint (and remembering to remove such code when I make commits) can be cumbersome.

I love what vim-ruby-debugger does in terms of dropping a visual breakpoint into the editor without actually modifying my project's source code, but I've had some trouble getting this to function in the context of my specs (and I'd really prefer to just use Pry 'breakpoints' in the first place).

So the question is, is it possible to drop a binding.pry reference into a file such that an editor like Vim (or Sublime Text, etc.) will pick it up and respond appropriately at debug-time without the line actually be included in the source code?


You can use a Git Hooks to prevent a bad commit, like leaving a binding.pry in your code.

This article explains how to do it http://www.launchacademy.com/blog/posts/automatically-prevent-some-bad-git-commits

Here you are another good post about it http://www.ryanmcg.com/2013/8/12/another-forgotten-binding-pry/

Also I totally agree that PRY is an exceptional Gem.


http://www.vim.org/scripts/script.php?script_id=4451 seems to solve what you want. I haven't tried it personally, but I am going to :).


First off, PRY is an amazing tool and I am glad you found it.

is it possible to drop a binding.pry reference into a file ... without the line actually be >included in the source code?

You need to drop a binding.pry directly in the source code for it to go into pry to test and play around. FYI if you drop a binding.pry into your spec file it will open pry IN the spec file not what it refers to.

You can try better_erros with binding_of_caller and when you run a failing rails server, a) it gives you a better error feel and gives you a direct pry box to the error.

链接地址: http://www.djcxy.com/p/13694.html

上一篇: 在Oracle SQL中选择xpath值作为单独的行

下一篇: 使用Vim中的Pry调试器样式断点