In my installation of RStudio, even with Emacs keybindings, I was not
able to use M-w
(i.e., Alt-W
) for copying.
In the Tools | Modify Keyboard Shortcuts… menu, it is not possible
to bind keys to the copy
command.
C-w
and C-y
work fine for killing and yanking, respectively.
altw
is an RStudio addin to copy the current selection to the
clipboard.
If there are multiple selections in the active document (made with
multiple cursors), the altw
concatenates them with \n
as the
separator before copying.
As any addin, it can be bound to a keyboard shortcut.
Now I can use M-w
to copy text to the clipboard, as in Emacs.
You can install altw
from GitHub with:
# install.packages("devtools")
devtools::install_github("fnaufel/altw")
After installation, go to the Tools | Addins | Browse Addins…
menu, find altw
, select it, and click on Keyboard shortcuts
to bind
it to your favorite key.
This addin uses the great clipr
package.
If you’re using any distribution of GNU-Linux with X11, you need to have
the xclip
program installed.