You can enable Emacs keybindings within the RStudio IDE from the Code section of the Global Options dialog:
A base set of Emacs keybindings for navigation and selection are available, including:
-
C-p
,C-n
,C-b
andC-f
to move the cursor up, down left and right by characters -
M-b
,M-f
to move left and right by words -
C-a
,C-e
to navigate to the start, or end, of line; -
C-k
to ‘kill’ to end of line, andC-y
to ‘yank’ the last kill, -
C-s
,C-r
to initiate an Emacs-style incremental search (forward / reverse), -
C-Space
to set/unset mark, andC-w
to kill the marked region.
There are some additional keybindings that Emacs Speaks Statistics (ESS) users might find familiar:
-
C-c C-v
displays help for the object under the cursor, -
C-c C-n
evaluates the current line / selection, -
C-x b
allows you to visit another file, -
M-C-a
moves the cursor to the beginning of the current function, -
M-C-e
moves to the end of the current function, -
C-c C-f
evaluates the current function.
We've also introduced a number of keybindings that allow you to interact with the IDE as you might normally do in Emacs:
-
C-x C-n
to create a new document, -
C-x C-f
to find / open an existing document, -
C-x C-s
to save the current document, -
C-x k
to close the current file.
This is a happy day! Thank you for adding this!
Thanks again for adding emacs keybindings. A couple things I've noticed:
the "undo" keybinding is only bound to
C-x u
. My fingers know one of the other aliases,C-S-_
(I like it because it doesn't require consecutive key hits), but when I tried modifying the shortcut, it doesn't work. In fact, after changing the "Undo" shortcut toC-S-_
and then closing and opening the preference pane, my custom shortcut gets changed toCtrl+Shift+Insert
I've noticed an inconsistency with killing and yanking lines, i.e. doing
C-k
followed byC-y
. In Emacs, consecutive applications ofC-k
will keep adding to the kill ring (provided no other command interrupts the killing), so thatC-y
will yank them all back together. For example, I might useC-k
to kill 3 consecutive lines, and then yank them all back with a singleC-y
. However, in RStudio, only the last killed line gets saved to the kill ring.Hi Clark,
Thanks for the feedback! I'll see what's going on re: the remapping from
_
toInsert
.The kill + yank behaviour is also currently suboptimal; the 'kill ring' is not yet fully implemented. We mostly borrow this functionality from the Emacs mode that's bundled with the Ace editor (http://ace.c9.io/#nav=about), but I'll see if we can either patch RStudio to implement this or else get changes adopted upstream in Ace as well.
Thanks,
Kevin
I love the emacs keybindings, but C-f opens the find pane inside the editor instead of moving the point forward. I there a way to change that?
Hi William,
Thanks for pointing this out -- I've logged an issue internally and we'll try to get this fixed soon.
Best,
Kevin
THANK YOU THANK YOU THANK YOU! :D
RStudio was already such a big leap up in productivity for me from Emacs/ESS that I have been using it almost exclusively for some time; but this was the one gripe I still had (old habits dying hard and all). Thanks so much for actually implementing this!
C-c C-n does NOT evaluate the current line/section, in fact C-c does not seem to be working at all. I'm using the current version of rStudio. C-r does evaluate the line but that should be search in reverse for emacs keybindings.
Hi Jared,
Thanks for reporting the issue -- we'll investigate what's going on.
Best,
Kevin
THANK YOU! I remembered asking for emacs key bindings in 2014 JSM at RStudio booth. It's finally here:)
Will full custom key settings happen in the future?
On Windows, what key acts as "meta"? Neither "alt" nor "esc" seem to work as meta.
Ubuntu 16.10 "M-b, M-f to move left and right by words" don't work, as they open the Build and File menus. Would it be possible to fix this?