15 Most Recent [RSS]
More...
|
Getting more out of Xcode with regular expression search
A neat tidbit that many people overlook is Xcode's Find in Project window, which is the more powerful of Xcode's two search windows. Right next to the "Search" and "Replace" text fields, there are two popup menus that I use the most in this window. The upper popup lets you select where to search. Want to know what's new in Mac OS X 10.4? Choose "Frameworks" here, then search for "MAC_OS_X_VERSION_10_4", and voilà, you can just click to see the APIs in the headers. Get too many irrelevant results for a search term from the system frameworks? Choose "Project" here and see where you are using that term.
But the second field is even more powerful. It lets you select how to search. Usually, you'll want Textual, which is your regular, run-of-the-mill partial string-matching search. Then there's Definitions, which pretty much only searches the implementation files and doesn't bother with function calls or forward declarations. And then there's the Unix-user's favorite swiss army knife: Regular Expression. Regular expressions let you search for complex partial matches.
Want to get rid of those #line 5 "sourcefile.y" directives a code generator littered all over your source to refer back to the original file? But you can't, because the line number is different each time. You could search for "#line" and just select up to the end of the line manually, but why not let the computer do that:
"#line(.*)\n"
(without the quotes) will match the entire line, starting with "#line" and ending on a newline. Then just replace that with nothing and they're gone. But that's just a simple example. The web is full of regular expression tutorials, and if you know a few basic things, like character classes and greedy and non-greedy repetitions, you can easily save yourself hours.
But if you want to, sure, you can still spend your time manually selecting to the end of each of those 300 lines...
| |