Book Image

TextMate How-To

By : Chris Mears, Christopher J Mears
Book Image

TextMate How-To

By: Chris Mears, Christopher J Mears

Overview of this book

Not all text editors are created equal. TextMate was created with versatility and power to the developer. Whether you want to organize your files in projects, utilize the efficiency of code completion, take advantage of the thousands of publicly available bundles, or gain insight using powerful regular expression searching, TextMate is an essential and easy-to-use tool you need in your development arsenal. "TextMate How-To" is a practical guide filled with conventional recipes on using one of the most popular text editors on the OS X platform. It is a great resource for anyone who wants to learn how to code more efficiently and effectively, no matter what programming or scripting language you use. This book will guide the reader through using TextMate for practical purposes. It will start with configuring the application, then cover navigation and editing of files, and finish with bundles and advanced features. Throughout the book, the reader will quickly master the key features of the application through easy to follow tasks. Using this book, the reader will learn the most common text editing and coding tasks including navigation through the document and searching of text. The reader will then learn about working with and navigating between files and projects as well as utilizing bundles to greatly speed up development. Finally, explore the ability to use shell commands and macros to increase productivity. With just a few hours, "TextMate How-To" will teach the reader everything necessary to hit the ground running with this powerful text editor.
Table of Contents (7 chapters)

Finding text in a project (Must know)

This task describes another way to find text, this time searching through your entire project. This task will also include some tips on how to speed up your search and even cover some caveats for larger projects.

Getting ready

Open or create a project with multiple files.

How to do it...

To pull up the Find in Project dialog window, from the menu, select Edit | Find | Find in Project… (Command + Shift + F).

How it works...

The Find function works in very much the same way as Find in a File (Command + F). However, it will return the locations of all of the occurrences of your find in every file of your project, except for the binary files.

  • Go to occurrence: If you'd like to open the file and go to the occurrence of the find, just click on the occurrence in the list as shown in the following screenshot:

  • The Replace Selected option: This option will only replace the occurrences of the find with the replace string for the current selection of occurrences. You can select multiple occurrences by holding down the Shift or Command keys while selecting. This is shown in the following screenshot:

  • The Replace All option: As expected, this will replace all of the occurrences of the find with the replace string regardless of what files are selected.

There's more...

Let's look at how to hide extraneous find results and speed up searching in large projects.

Hiding find occurrences

If you get a lot of results back and want to hide some occurrences to make it easier to replace selected occurrences, you can fold or collapse those results by clicking on the triangle next to the file, as shown in the following screenshot:

Tips to speed up searching

As mentioned in the Creating projects section, you can speed up searches by excluding files from your project. One method to do this is to create a new project with only the files you wish to search (for example, a particular folder or group of folders). The steps to implement for faster searching are as follows:

  1. Select the folders and/or files you wish to search in Project Drawer.

  2. Create a new project (Command + Control + N).

  3. Drag-and-drop the selected files and/or folders into the new project's Project Drawer menu, as shown in the following screenshot:

  4. Perform a Find in Project (Control + Shift + F) action on the new project, as shown in the following screenshot: