11

The normal search function (ctrl + f) in R-Studio just searches the currently selected file. Is there a way to search all open files?

Tom Evans
  • 413
  • 1
  • 5
  • 13
  • ls() only lists objects in the current environment. I wanted to search for some string within files (e.g. R scripts) in a project. I should have made it clearer. Josh's solution is perfect for my use. – Tom Evans Feb 04 '13 at 15:10

1 Answers1

17

Tom,

Check out the following documentation:

http://www.rstudio.com/ide/docs/using/navigation

There isn't a way to specifically search only the open files in your source editor for a given string, but you can either use "Find in Files" or "Go to File/Function".

Josh

Product Manager - RStudio

Josh Paulson
  • 437
  • 4
  • 6
  • does that extend to search and replace in all open files in some way? – Christoph Hanck Sep 23 '15 at 09:03
  • 2
    I am looking to do search and replace in multiple files at once. This happens when one renames functions that get used in multiple other .R files. The find in files function does not seem to have a replace feature. – CoderGuy123 May 03 '16 at 14:06
  • @Deleet: https://stackoverflow.com/questions/34251931/renaming-objects-in-rstudio-context-sensitive-within-entire-project – Scarabee Jun 05 '17 at 13:56
  • 1
    @Scarabee That won't work across multiple files. @Deleet This linux command line script will do the trick: `find ./ -type f -name '*.R' -exec sed -i 's/original_string/replacement_string/g' {} \;`. It will replace the string in all R files in all subdirectories. To test it first without changing anything: `find ./ -type f -name '*.R' -exec sed 's/original_string/replacement_string/g' {} \; | less` – Juergen Dec 06 '17 at 11:24
  • Two features that would be a major improvement to the functionality of this feature: 1) recursive search in all folders within the current folder, and 2) as mentioned above, find *and replace* – Nibood_the_slightly_advanced Aug 19 '19 at 13:50