Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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

share|improve this question

2 Answers 2

up vote 8 down vote accepted

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

share|improve this answer

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.

share|improve this answer
    
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. –  Gilles Feb 24 '11 at 20:53

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.