Gunnar
Gunnar

Reputation: 107

Stop R studio from jumping to the next function

There's this one issue with Rstudio that has been bothering me for a long while now and I cannot find a solution. I like to use a lot of shortcuts and move around the editor with arrow keys and also scroll the editor using Ctrl + arrow shorts. The issue is that if the script contains a user defined function and I press Ctrl+Up/Down the cursor jumps to that function even if it's nowhere near. Like sometimes hundreds of lines. EXTREMELY ANNOYING!!! And I have looked through shortcuts and this is the only thing I have found: enter image description here

There are no more different Ctrl+Up/Down shorts. So it doesn't seem to be a multi mapping issue. Also if I change this mapping to something else the annoying jumping still continues. I just want it to stop! Can anybody help? Doesn't it annoy anyone else?

Upvotes: 3

Views: 449

Answers (1)

Jack Aidley
Jack Aidley

Reputation: 20107

The behaviour of RStudio where Ctrl+Up and Ctrl+Down step the cursor between function definitions is not configurable and cannot be changed. Oddly, the same pair of keystrokes were chosen to move the scroll bar.

Your only option to avoid the conflict is to redefine the scroll up and scroll down keystrokes to something else (e.g. F8/F9 or something) so that they not longer conflict with this hardcoded option. You can then control the scroll bar using the keystrokes you have chosen without it conflicting with the behaviour where it steps between functions.

If you find you have accidentally navigated to a function you didn't want using Ctrl+Down, you can return the cursor to where it was using the "Source Navigate Back" keystroke which defaults to Ctrl+F9.

IMO this is clearly a bug in RStudio. I would report it to them and hope that it is fixed for a future version.

Upvotes: 3

Related Questions