TextMate Power Tips

I recently gave an ignite-style talk about TextMate power tips, in the context of craftsmanship and tools. In the talk I only had time for a few of my favorite tips and tricks, which I’d like to share with you—plus a few more.

Projects & Opening Files

mate Quickly open files from the command line—a simple yet powerful technique. You can also use it to send output from other commands into a TextMate document. For example, take stdout and open in TextMate: ls | grep foo | mate. Or just open a file: mate foobar.txt.

Dragging files or folders to TextMate icon on the Dock creates a new project with the selected items. Running mate on a directory or set of files will make a new project in TextMate.

Cmd-t Find a file in a project quickly. Super handy if you have tons of tabs open, or files nested deep inside folders.

Example of Cmd-t to open a file quickly.

Cmd-Ctrl-r Reveal current file in project drawer. Great for when deep down in a nested project and you need to see the context.


Ctrl-< Make an HTML element from a word file. This is smart enough to know the self-closing tags (img, hr, br, input).

Ctrl-Shift-w Wrap selection in HTML tags. Useful for wrapping a bunch of lines with lis when making a list.

Ctrl-Shift-l Wrap text as a link, taking URL from clipboard.

Cmd-Opt-. Close an element, based on the opening tag.


Cmd-Shift-c Insert a color value from the OS X color dialog, adding it to the current document as a hexadecimal value.

Ctrl-q Format CSS, also works in other formats like HTML.

! Type an exclamation point then use the tab key to insert !important quickly.


Cmd-Opt-] Align assignments for code prettification, like in arrays or variable declarations. Select the lines you want to align, and then invoke the command.

Ctrl-Shift-' Toggle single/double quotes. For example, if your cursor is inside the quotes on the word node in code like this: array( "node" ); you would use this command to toggle to single quotes.

Ctrl-Shift-v Check syntax, also works in other formats.

Cmd-/ Comment/uncomment a line or block, also works in other formats.

Esc Complete a word based on the current document. I use this one often, especially for super-long variable names in PHP files; I just type the first few letters of the variable and hit Esc until I find a match.


Ctrl-u Convert text to uppercase. Use Ctrl-Shift-u for lowerase and Ctrl-Opt-u for title case.

F5 Sort lines in the document, with an option to remove duplicates.

Ctrl-s Inline search: keep hitting the same command to find the next result in the document.

Opt-click Select columns and edit. Multi-line editing with column selection in TextMate is pretty sweet. This functionality can save lots of time by editing multiple lines in the document at the same time. It’s hard to explain with text and a screenshot, so here’s a video example: http://macromates.com/screencasts, look for Working With Numbers & Columns.

Commands & Snippets

TextMate is at its best when you extend it with your own snippets and commands to go along with all the great ones that come bundled. For example:

utc Add a UTC time stamp in any file, using `date -u +%D\ %R` UTC as the snippet triggered when you type those letters and hit tab.

bbug Add border: 1px solid red; to a stylesheet for a quick CSS debug in a browser.

See Using TextMate for WordPress Code Cleanup for two useful commands: removing trailing whitespace from files and changing spaces to tabs at the beginning of lines.

Finding commands and snippets within all the options available in TextMate can be challenging—unless you commit their shortcuts to memory. Enter one of my most-used keyboard shortcuts in TextMate (bundles are groups of commands and snippets).

Cmd-Ctrl-t Look up a bundle item, greatly useful if you forget a shortcut, or need to find something obscure. It only shows results for your current file type, but you can override it by typing in ALL CAPS.

I use this one all the time since I don’t want to memorize the shortcut for every possible command or snippet. Instead I just start typing a few words, hit this command, find what I need in the list, then apply it with Enter.

Example of finding a bundle item with Cmd-Ctrl-t.

Much More

There is so much more to TextMate, of course. Macros, Subversion integration, lots of great add-ons like AckMate and ProjectPlus, and the list goes on.

Further reading:

Published by

Lance Willett

My name is Lance, I am a blogger, product manager, software developer, and business executive creating high-quality, engaging, and customer-centered experiences for people online. México-born.

2 thoughts on “TextMate Power Tips”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.