Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to edit with multiple-selections in RStudio?

Tags:

r

rstudio

names(mydata)[names(mydata)=="q1"] <- "q01"  

I want to select 2 mydata at the same time and then can edit them at the same time.

Some advanced text editors let you have multiple cursors, so that, for example, if I select both "mydata" in this line, and then hit delete and type "otherdata", I end up with:

names(otherdata)[names(otherdata)=="q1"] <- "q01"  

Although this can be done here with a simple search and replace, sometimes having multiple selection and multiple cursors is possibly easier.

The Sublime Text editor can do this, as can Atom and Emacs.

like image 967
kittygirl Avatar asked Jun 11 '17 01:06

kittygirl


People also ask

How do I run a highlighted code in R?

To execute the line of source code where the cursor currently resides you press the Ctrl+Enter key (or use the Run toolbar button): After executing the line of code, RStudio automatically advances the cursor to the next line.

How do I run an AR program in RStudio?

To run an R command, put the cursor on the line of the command and then click the Run button at the top of the file window. Or just press CTRL-Enter.


1 Answers

From Rstudio conf-2017

  1. place your cursor on one of the mydata terms
  2. Press Ctrl + Alt + Shift + M: "Rename in scope. Refactoring"

This will select all the matching terms in your code

  1. Use the arrow keys to move the multi-cursor to the position you want to start editing.
  2. Press esc when you are finished
like image 177
Greg H Avatar answered Oct 14 '22 12:10

Greg H