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)

Folding (Should know)

Folding is a great way to organize your code as well as hide lines in order to focus on the current task at hand.

Getting ready

To use folding, you'll need to make sure it's enabled. You can toggle it by going to View | Gutter | Foldings from the menu.

How to do it...

Folding actually happens automatically as long as you have the proper language selected via the status bar pop-up:

How it works...

As with most of TextMate's functions, learning the keyboard shortcuts for folding is key to working with your document.




Fold current block.

Option + Command + 0

Fold All Levels toggle.

Option + Command + 1Option + Command + 9

Fold at level (1-9).

But, you can also use the mouse and click the arrows to fold the code, as shown in the following screenshot:

There's more...

It's important that your document is set to the correct language for folding and other features, such as bundle snippets and shortcuts, to work properly. You can quickly change languages using keyboard shortcuts.

Language keyboard shortcuts

Notice the keyboard shortcuts next to the language selection pop-up. These can be very helpful in quickly switching languages (for example, between HTML and PHP or HTML and JavaScript).

Sometimes the document is coded in two languages (for example, HTML and PHP) and you need certain bundle functionality, depending on the setting (bundles will be discussed further in the Bundles recipe).