Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find and replace in selection or single file - Xcode 4.5

Tags:

xcode4.5

I'm stuck with a bit of an Xcode puzzle: how can I find and replace either in a selection I've made, or at least just in a single file?

According to the following topic there's a way to hold down the option key and Replace All should change to Replace in Selection:

How can I find and replace inside a selection in Xcode?

This either doesn't happen in Xcode 4.5, or I don't know how to do it. Right now I can bring up the find/replace option in the search navigator on the left, then hit return to search, or hit preview to bring up which files are to be changed.

As a workaround, I can search in a selected group (by right-clicking on a group in the file navigator), but being able to replace in a selection I've made, and in a single file would be extremely helpful.

Thanks in advance ;-)

like image 782
Jay Versluis Avatar asked Jan 18 '13 15:01

Jay Versluis


People also ask

How do you do find and replace in Xcode?

In the toolbar search, you have to press 'Find' then a menu appears – pick replace. Now you can replace project-wide.

How do I replace text for entire project in Xcode?

Xcode displays the results of the search, but it doesn't automatically replace the text. To replace the text for a single result, select it and click the Replace button. To replace the text for all results, click Replace All.

How to search entire Xcode project?

To find text in a file, open the file in the Xcode source editor and choose Find > Find from the menu bar. Xcode displays the Find bar and its search controls at the top of the file. Enter a search term. Xcode searches the file, highlights matches, and notes how many it finds.


1 Answers

In Xcode 4.6 (I don't have 4.5 on my system any more to check it), if you are in the editor window and press Cmd-F to bring up the Find view at the top of the editor (as opposed to the global search inspector you are referring to), and use the Replace option in it, holding down the Option key changes "Replace All" to "In Selection". This seems reasonable since the global search inspector is across multiple files while the option to choose "In Selection" really only makes sense when you are referring to a single file.

like image 175
Dave Reed Avatar answered Dec 06 '22 07:12

Dave Reed