36

In byebug we can move to next line by typing 'n', similarly is there anyway to move to the next line in 'pry' ?

I have gone through there documentation but nothing's works out.

vikas95prasad
  • 1,234
  • 1
  • 12
  • 37

3 Answers3

28

Check out pry-nav, it gives you methods like next and step, which should be what you're looking for.

If you're in regular old Pry you can use exit to go to the next binding.pry or disable-pry to exit Pry entirely.

garythegoat
  • 1,517
  • 1
  • 12
  • 25
  • 5
    There's also [`pry-byebug`](https://github.com/deivid-rodriguez/pry-byebug) to combine these two libraries. – Tom Lord Nov 27 '17 at 17:43
  • @user9015957 What do you mean, "it doesn't work"? You need to be a bit more specific about exactly what you have tried and what errors you are seeing. I suggest you create a new question with a more complete description of the problem, if you are still having difficulty. – Tom Lord Nov 28 '17 at 09:56
  • It seems like `pry-nav` and `pry-rails` currently require different versions of `pry` and are incompatible. – mtrussell May 12 '21 at 16:01
20

You can't. pry doesn't have any command who let you jump to the next line. So, your alternatives are:

  1. Adding a new pry.binding on the next breakpoint and then using exit to jump between bingings.
  2. Using a gem like pry-byebug or pry-nav who adds the next command to jump to the next line.
  3. Using a gem like pry-byebug or pry-debugger who adds the break command to add breakpoints like break <Class#method>.

Installing pry-byebug is the best solution for your case, you can't achieve this with just pry.

lcjury
  • 1,158
  • 1
  • 14
  • 26
4

you can exit to continue the code flow

a131
  • 544
  • 3
  • 12
  • Why was this answer down voted? Please leave comments when down voting answers. This is the correct answer without using any additional libraries. – a131 Nov 27 '17 at 17:47
  • 3
    Because he is asking how to go to next line not how to exit the breaking point, just like 'next' || 'n' in byebug – Sherif Elkassaby Jan 09 '19 at 12:29
  • He is asking how to go to the next line in binding.pry. When you use binding.pry, the flow of the execution stops on that line and to resume the flow you use exit. If you want to stop at the next line, you can place another binding.pry there but that would be kind of pointless – a131 Jan 09 '19 at 12:33
  • instead of placing multiple pry you can use gem 'pry-byebug' to take advantage of both gems – Sherif Elkassaby Jan 10 '19 at 09:52
  • You are right but I was trying to answer him without any additional gems. Why would anyone place multiple binding.pry :p – a131 Jan 10 '19 at 11:34