Folding is a great way to organize your code as well as hide lines in order to focus on the current task at hand.
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.
Folding actually happens automatically as long as you have the proper language selected via the status bar pop-up:

As with most of TextMate's functions, learning the keyboard shortcuts for folding is key to working with your document.
Shortcut |
Description |
---|---|
F1 |
Fold current block. |
Option + Command + 0 |
Fold All Levels toggle. |
Option + Command + 1–Option + 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:

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.
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).