Profile photo of marc

by

Staring into the Fire: Search and Replace

August 4, 2014 in Fire

This post is part of a series in which I want to take a closer look at some of the features and functionality in Fire, our new IDE for the Mac. In this post, I’d like to look at Search and Replace.

Search and Replace is a core feature of any development environment, so of course Fire has sophisticated support for it. The basics work pretty much exactly how you would expect, but Fire goes a bit beyond, so let’s look at the feature in detail.

To start with, as you would expect, you invoke Find/Replace using the standard Cmd-F keyboard shortcut (or via Edit|Find in the menu), which brings up the Find/Replace popup:

Here, you can type a search term and — as you’d expect — you can also choose whether this search term should be treated case sensitive, whether to match whole words/tokens only, or whether to treat the term as a RegEx. As you make your selection here, you will see that it will automatically reflect in the open editor, highlighting every occurrence of the search term in text marker yellow. This will persist even as you dismiss the Find/Replace popover.

What’s more, the search term and settings will automatically synchronize between all files you have open — all across your project, and even across multiple solutions. So as you switch files, or switch to a different document window, you will see your search term is highlighted everywhere. And, like just about all state in Fire, it will also persist across restart of the IDE.

The Find/Replace popover gives you the usual options to Find Next, Find Previous, and of course to replace either one or all occurrences of the search term with a new string.

After you dismiss the Find/Replace popover, these options continue be available via keyboard shortcuts and the Edit|Find menu. Cmd-G will jump to the next occurrence, and Shift-Cmd-G will jump to the previous, both allowing you to cycle round-and-round in the current file. Option-Cmd-G will replace the current/next occurrence of the search term, while Control-Option-Cmd-G will replace all in the entire file.

When replacing, you will notice that the editor also highlights each occurrence of the replace term as well, with a more subtle yellow. This highlighting allows you to easily keep track of what matches your search and what has been replaced already.

If you had enough of your search, you can clear the search term, and make the yellow highlights disappear with it, by pressing Control-Option-Cmd-F (or choosing Clear Search Term from the Edit|Find menu).

But that’s not all. One frequent task while navigating code is navigating between occurrences of the same token, so Fire has a shortcut for that as well. When the cursor is on a word/token, you can press Control-Option-Right or Control-Option-Left to quickly jump to the next (or previous) occurrence of that token. Fire will automatically make the token at the cursor the current search term (so you will see it highlighted all across the file). If not already turned on, Fire will also temporarily enable the “whole words only” option for this search to make sure you only find the exact token (if you want to jump from one use of ‘i‘ to the next, you don’t want to also hit the ‘i’ in ‘begin‘).

When you do a manual search later, the “whole words only” will automatically revert back to its original setting. You’ll find that the Control-Option-Right or Control-Option-Left navigation is something that, once you’re used to it, you can no longer live without

All in all, Fire’s Find and Replace support is well-rounded and — along with Fire’s other navigating mechanisms that I’ll dive into in another post — designed to make it really easy and intuitive to find your way around your code.

3 responses to Staring into the Fire: Search and Replace

  1. Nice…with the Laz version of SynEdit you could have folding man ;)

    • This isn’t written in Delphi or FPC though, and not using SynEdit. Fire is a fully native Cocoa app, and we’ve written our own code editor control from scratch, for maximum flexibility/.