Jump to Any Line While Debugging
The IntelliJ IDEA debugger is very helpful when it comes to improving your code. Not only does it help you to identify inconsistencies, but it also makes navigating to the responsible lines much easier.
There are many ways to set a target execution line during debugging. You can use breakpoints, or step to the line using the Step Over (F8), Step Into (F7), and Run to Cursor (⌥F9) commands. But what if you want to jump to a particular line and set an execution point there, without executing the preceding code?
Surprisingly, at the moment you can only do this with the help of workarounds, and this is where the Jump to Line plugin comes in handy. When the program is suspended, this plugin allows you to drag and drop an arrow in the Gutter area, putting an execution point at the desired line. This saves you time because instead of performing several actions – like setting a breakpoint and waiting for the program to pause, or applying a two-handed shortcut combination – you can just hover your mouse to the exact place you want to be.
Jump to Line enables you to move either forward or backward within a function. When you drag the arrow, the IDE highlights in green the code lines at which you can set execution points.
With the plugin, you can interrupt the control flow. For example, you can change the if-else branch.
What’s more, you can force the loop to break, or restart it from any iteration.
If you need to move back but do not want to use Drop Frame to rewind the execution of your code, Jump to Line works for you.
Remember the following when you move back and forth through your code:
- Making changes to some lines may break the workflow. That’s why the IDE will highlight them in yellow. You can still move to them, but you need to be aware of possible consequences.
- If you press and hold the Ctrl / ⌘ button while dragging the arrow, the IDE will highlight all the lines in green. When you drop the arrow, you won’t jump to the line of code. Instead, the IDE will act as if you have used the Run to Cursor (⌥F9) action.
- If you jump over the line at which a variable is initialized, this variable will take the default value (like zero for numbers and null for references) upon running.
- The main method and the Kotlin suspend functions are restricted for jumps.
- It is impossible to move to the execution point into another function.
- The plugin works for Java and Kotlin only. Android and other JVM-translated languages (like Dalvik) are not supported.
To sum it all up, Jump to Line can improve your productivity when you need to get to a specific line of code quickly, as it allows you to skip unnecessary actions like rerunning the program, setting additional breakpoints, or stepping.
Boost your debugging routine with us!
Subscribe to Blog updates
Thanks, we've got you!
Import Postman Collections to the HTTP Client
We know that many of you use Postman collections and want to stay in the flow while working with them. This means staying inside IntelliJ IDEA and not switching to a different app. Great news! You can now effortlessly transform Postman collections into .http and use them in the HTTP Client …
What’s New in IntelliJ IDEA 2023.1 for Spring Developers
The IntelliJ IDEA 2023.1 release came packed with updates for Spring. This blog post will highlight the most noticeable changes, including full support for Lombok, a reworked Spring tool window, navigation for Spring Security rules, Spring Security 6 support, and more. Remember that these featur…
‘Quick’ Features in IntelliJ IDEA
A few IntelliJ IDEA features or actions include the term ‘quick’. Do they speed up certain processes? Let’s find out. In this blog post, I’ll cover what these features are, why you need them, and how you can use them. 1. Quick Lists If you have actions that you use regularly but don’t have shortcut…
5 Best Features for Profiling Java Code In IntelliJ IDEA
When it comes to apps functioning efficiently, there is always room for improvement. Fast, lag-free, smooth operation – what else can a Java developer dream of? However, when you aim for this level of perfection in your app, you will need a comprehensive toolset to monitor performance and identif…