user3115933
user3115933

Reputation: 4443

How can I insert a line of text above the occurence of a specific text in a long R Script?

I have been looking for a solution to this problem but could not find a practical one. I have a long R script (more than 1500 lines).

I have the following text which repeats itself several times in the Script:

df00$StartDate

I need to add the following line of text just above it (everywhere where it occurs):

df00$`MealPlan` <- sub('\n.*', '', output3$`Your choices`)

Is there an efficient way to do this instead of scrolling through the Script and manually pasting that new line of code?

Upvotes: 1

Views: 311

Answers (1)

zx8754
zx8754

Reputation: 56159

CTRL+F search for df00$StartDate, then click "All", then start editing, the edit will be done for all selected rows at the same time.

See screenshot, you will see a multiline cursor at the end of each line:

enter image description here

2015-05-06: RStudio v0.99 Preview: More Editor Enhancements

Upvotes: 2

Related Questions