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
Build a Spring Boot App with AI Assistant
In this article, we’ll be building a small Java Spring Boot web application in IntelliJ IDEA with the help of JetBrains AI Assistant. If you’d like to follow along with this tutorial, you’ll need IntelliJ IDEA Ultimate, as well as an active subscription to AI Assistant or the free seven-day trial…
Top 10 UI Updates in IntelliJ IDEA for 2023
Hey there, fellow developers! Today, we want to share the most significant UI updates from 2023 that have transformed how IntelliJ IDEA looks and functions. New UI Of course, the highlight of our recent updates was the launch of our new, clean, and modern UI. This was first announced at the en…
The What, Why, and How of JPA Buddy in IntelliJ IDEA
Master JPA entity management with JPA Buddy in IntelliJ IDEA! Our latest article shows you how to simplify your workflow and reduce boilerplate code.
The Best of IntelliJ IDEA’s HTTP Client
In today's fast-paced tech world, easy and efficient management of web services and APIs is crucial. That's where IntelliJ IDEA's HTTP Client steps in, turning complex HTTP requests into a walk in the park. The HTTP Client is a feature-rich, text-based tool in IntelliJ IDEA Ultimate. It seamlessl…