Reputation: 30035
In Xcode < 4, you could hold the "option" key, and the "Replace All" button would change to "Replace in Selection". As of Xcode 4, this does nothing. Anyone know if there's a new way to do it, or is it bug filing time?
Upvotes: 53
Views: 25336
Reputation: 512206
A few images to supplement the chosen answer:
And holding down Option:
See also
Upvotes: 13
Reputation: 866
This appears to be working again now, at least in Xcode 4.4.1.
When the find/replace bar appears at the top of the editor, holding down the option key on the keyboard causes "Replace in Selection" to appear in lieu of "Replace All."
I'm glad, because this was an ANNOYING omission.
Upvotes: 74
Reputation: 584
To replace text in a selection using Xcode 9
Once you understand that you make your selection AFTER you have entered the search string, then this is not that clumbersome and works fine.
Upvotes: 1
Reputation: 1479
EthenA.Wilson asked in a comment to the OP a couple of days ago:
"Is there a way to do this in Xcode 5?"
For the benefit of those who, like me, had been searching for it, here's how:
After you put your Find and Replace terms in the bars at the top left-hand side of the editor page, select the text you want to search in, then look at the top right-hand side (same bar). You'll see where it says "All", right next to "Replace." Now press the Option key. "All" will change to "All in Selection." Click it, and you're done. Could be a bit more intuitive, but the functionality is there in Xcode 5.
Naturally, good idea to take a snapshot before you click!
HTH!
Upvotes: 0
Reputation: 1047
I find alt-command-f easier for local find and replace (4.3) and then working around your selection.
Upvotes: 0
Reputation: 676
Not ideal, but not too bad:
Upvotes: 1
Reputation: 735
Another workaround:
In a terminal session:
pbpaste|sed 's/SOURCETEXT/NEWTEXT/g'|pbcopy
Return to Xcode window, press paste
Since the original should still be selected, it will just be replaced. You could probably build a simple shell script to do this.
Doug
Upvotes: 16
Reputation: 1475
There is another way only replace the matches you find, rather than just this one or all of them.
I suggest you save a copy first, just in case....
Hope that helps, it did me.
Upvotes: 2
Reputation: 31
I'm upset that they took out this functionality, as I used it constantly, but here's my workaround. Copy your selected text from Xcode4 to TextEdit or some other word processor, do the find and replace there, and then copy the results back into Xcode.
It's not sexy but it's worth it if you do a lot of these "find and replace on my selection", and you leave the word processor open in Spaces as you work.
They should add "my selection" as an alternative to "workspace" and "my scope".
Upvotes: 3
Reputation: 185711
Seems like missing functionality. You should file a bug report.
Upvotes: 9
Reputation: 19
Not sure which feature prior to Xcode 4 you're referring to, but the shortcut Command+Shift+E gives you "Use Selection for Replace". If you're talking about "Find and Replace in Workspace" (Command+Option+Shift+F), then what you need to do is run your find and then hold down "Shift" or "Command" on the selections shown and then hit "Replace".
Upvotes: -1