4

How does one find and replace text in all open files with gedit?

2 Answers 2

9

This is not possible with a stock gedit; there's an open ubuntu brainstorm idea for adding the ability. However, there are plugins that add it, such as advanced-find. If you install that, one of the sections on the "Advanced Find/Replace" dialog is "Scope"; choose "All Opened Documents":

Screenshot of the Advanced Find/Replace dialog

2

Generally people who want to do this write an ed script and run it against all the files. E.g.:

*s/ThrityLimit/ThirtyLimit/
w
q

And then run it like this

find . -name '*.c' -exec "ed <edscript"

You can also use an ex script which allows you to use all the : commands from vi. It's the same binary as vi just called using the command ex to start without the gui.

2
  • 1
    or with GNU sed: sed -i -e 's/ThrityLimit/ThirtyLimit/g' *.c. Or perl -i -pe 's/ThrityLimit/ThirtyLimit/g' *.c. With zsh or bash 4, you can traverse subdirectories with **/*.c. Feb 24, 2011 at 20:53
  • "How does one find and replace text in all open files" indicates that the user already has selected which files to apply the edit to. This answer does not address that aspect of the question nor does it address the "with gedit" component. Mar 14, 2018 at 18:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .