Find and replace text in all files in Rstudio

11.9k views Asked by At

I am wondering why, still, there is not a feature in Rstudio to search all files in the current project (package) and replace a given text!? Or maybe there is one and I am not aware of!

ctrl+shift+f only finds in all files without replacement.

ctrl+shift+j (or ctrl+f) finds and replaces in the current file.

5

There are 5 answers

0
Jot eN On BEST ANSWER

This is now possible with the 1.3 version of RStudio. You can learn more at https://blog.rstudio.com/2020/03/17/rstudio-1-3-the-little-things/.

0
Gonçalo Peres On

From what I have seen on this feature request, it is already available (this was the pull).

RStudio calls this Global Replace:

RStudio has long had a Find in Files feature, which makes it possible to easily locate text in your project. If you’re not familiar with this feature, try it out: press Ctrl+Shift+F (MacOS: Cmd+Shift+F), or choose Find in Files… from the Edit menu.

In RStudio 1.3, it’s now possible to replace the text you found:

enter image description here

After you’ve done a search, switch to Replace view via the toggle, enter your new text, and click Replace All. It works with regular expressions, too.

In order to test it, in RStudio in Windows, when one presses CTRL+SHIFT+F it opens the following

enter image description here

And one can search in the following files

enter image description here


To keep in mind:

You should be aware however that while we do hang out on the community site occasionally, the best place to make your request heard is on our Github issue tracker. (Source)

Also, this is how one write a good feature request.

0
Gorka On

This is the Rstudio Github issue related to the enhancement:

https://github.com/rstudio/rstudio/issues/2066

Feel free to vote up (thumbs up) the issue to bring more attention to it!

1
llrs On

The best I could find is this, it is a pending issue sine 2014:

Thanks for the feedback. We've got this as a feature request and I'll chalk up another request for this.

0
Sebastian Kranz On

I wrote a small RStudio Addin to replace in multiple files, which can be used until this functionality is included in some newer RStudio version. Here is a screenshot:

enter image description here

The package is briefly described in my blog post.