The default hotkey behavior in both Xcode and TextEdit “Find and Replace” is:
Find... ⌘F
Find and Replace... ⌘⌥F

However, in TextEdit, the dialog for “Find and Replace” remains even after you press ⌘F. In Xcode ⌘F hides the “Find and Replace” section of the dialog and only displays the “Find” part.

In TextEdit, ⌘F sets the focus (which means your text marker is in the box) in the “Find” textbox. ⌘⌥F sets the focus in the “Find and Replace” textbox. Pressing ⌘⌥F followed by ⌘F keeps the entire dialog open. In Xcode the focus is ALWAYS in the “Find” dialog, no matter what hotkey you invoked it with.

I prefer the TextEdit behavior, but would also like consistency. Is there any way to make Xcode behave as TextEdit in this regard?


Here is a Part solution for setting the focus for ⌘⌥F

Save this Applescript down as a Text file instead of a script.

tell application "Xcode" to activate
delay 0.5
tell application "System Events"

    tell process "Xcode"

        keystroke "z" using {command down, option down}
        delay 0.3

        keystroke tab
    end tell
end tell

In terminal.app

Make the script file executable by running

chmod +x /path/to/foo.applescript

In Xcode go to the Preferences-> Key Bindings Tab.

And change the Find and Replace (menu) 's hotkey to ⌘⌥z

enter image description here

Now still in Preferences go to the Behaviours Tab

Click the '+' button to add a new custom Behaviour.

Name it and give it the hotkey ⌘⌥f

On the right hand pane of the Behaviours Tab scroll down to the bottom

And using the Run dropdown choose script. Select your Script file.

enter image description here

Now you can use the ⌘⌥F and the find and replace will appear and focus will go to the replace field.

As to replicating the keeping the Replace in view if it is already showing when you hit ⌘F. I think that in most cases it is redundant because you will want to still hit ⌘⌥F to get back to the replace field and the Find's text field will still be show with the changes you just made.

  • I had no idea you could use scripts like that in Xcode. And I agree on your final point, though it would be nice to have a visual representation of what’s happening without having to always use ⌘⌥F and subsequently ⇧↹ several times… Your answer suffices for my usage, at least. Thanks a lot! – user118108 Mar 29 '15 at 19:18

You must log in to answer this question.