Replicate behaviour of ctrl + E and ctrl + A on Mac

Hitting ctrl + A on a Mac moves the cursor to the beginning of a line and hitting ctrl + E moves the cursor to end of the line, regardless of whether that line is wrapped onto subsequent lines. The yellow lines show where the cursor is moved to.

But hitting Home and End in RStudio only moves the cursor to end of the first line, and doesn't move the cursor to end of the wrapped lines.

How can I replicate the behaviour of ctrl + A and ctrl + E in RStudio?

1 Like

I agree this is annoying behavior! (RStudio also has Control-A and Control-E mapped to "Go to beginning/end of line" by default, and the same thing occurs). If you want to suggest this as a feature request, here's the guide for how to do so: Writing Good Feature Requests · rstudio/rstudio Wiki · GitHub

The current behavior seems to interact with soft-wrapping — in situations where the editor contents are soft-wrapped, "Go to beginning/end of line" actually goes to the previous/next wrap point. When you have soft-wrapping turned off, it does properly go to the beginning/end of the line (as indicated by the line numbers). I can understand the logic behind making the "end" of the line the wrap point when lines are soft-wrapped, but I find it is rarely what I actually want to do. FWIW, the MacOS shortcuts are officially described as "Move to the beginning/end of a line or paragraph".

Examples:

R script, no soft-wrapping

Control-E goes to end of line:
17

R script, soft-wrapping turned on in Global Options

Control-E goes to end of wrapped line (but see cursor position box in lower left: not actually the end of the line)
06

Text file, always soft-wraps

Control-E goes to end of wrapped line (but see cursor position box in lower left: not actually the end of the line)
36