Top 15 TextMate Shortcuts

TextMate by Macromates is by far the best code writing/development tool I’ve ever used. Not only is it awesome at face value, but the depth of features and extras make it the ultimate productivity booster when developing. What’s equally amazing is how it accomplishes this with no bloat. If you spend any amount of time editing code you need this application and the $62 will be well worth it.

So here is my list of top 15 most useful TextMate shortcuts that have saved me countless hours accomplishing simple tasks, and these just scratch the surface. Take some time to browse through the bundles to find ones that work for you. You can also create your own or edit the existing ones to suit your needs.

Shortcut Description
1. projects everyone should know about projects. create a new project and then drag files/folders into the sidebar or drag a folder into the textmate icon to create a new project. (thanks to Ben Lew for the tip on dragging a folder into the icon.)
2. regular expression search/search and replace check the ‘regular expression’ box and put your regular expression in the find. regular expressions are hard for me, but once figured out they are a huge time saver. with textmate you can capture parts of the find and insert them into the replace. for full information go to their regular expressions page.
3. cmd+shift+f find in project. useful for mass search and replace operations or just finding where a function is defined.
4. cmd+t go to file. opens up a dialog box where you can type the name of the file as well as use up/down arrows to navigate to it (within the open project).
5. cmd+shift+t go to symbol. this dialog box allows you to navigate to symbols within the open document. i use this a lot in php to navigate a large list of functions, or for css to navigate a long list of selectors.
6. option+selection selection outside of line restriction. when you hold down option the mouse pointer turns to crosshairs so you can select a portion of multiple lines. this is helpful when eliminating a tag from the end of even lines, etc.
7. option+tab/option+shift+tab or cmd+}/cmd+{ indent/un-indent a selection of items. if you need to indent or un-indent a selection of items you can highlight them and then option+tab them. these two shortcuts seem to be the same, anyone know if there is a difference?
8. ctrl+shift+w wrap selection in tags. select something and then invoke the shortcut to wrap it in open/closing tags. by default it’s a ‘<p>’ but you can type any tag and it will add it to both sides.
9. cmd+shift+7 convert selection to entities. i used this one a lot in creating this list, just select something and invoke the shortcut which will bring up a dialog box with options on what type of entity you want to convert the selection to (i couldn’t get this to work properly via shortcut, but you can use the menu: Bundles > HTML > Entities > Convert Selection to Entities).
10. ctrl+return insert a <br/>. i prefer to self close my <br/> tags, but by default it inserts a <br>, you can change it in the bundle editor.
11. ctrl+shift+l wrap selection in <a href=””></a>. hyperlink a selection. bonus: if you have the url already in the clipboard it will auto-insert it into the href.
12. cmd+shift+c color picker. this is used within css files to select a color, once selected it dumps the hex or rgb code for that color into your document. you can also select an existing color code and toggle this window to have a starting point.
13. ctr+shift+t to-do list. this feature scans your project for items labeled with ‘FIXME:’, ‘TODO:’, ‘CHANGED:’ and provides a list of them along with their comments and a link to that file and line. (thanks to Gordon Brander for this tip.)
14. kv ⇥ streamlined way of inserting key/value pairs for arrays. it has tab stops at the necessary spots. this goes well with ‘array ⇥’. create new tab trigger and add:

'$1' => ${3:'$4'},$5
15. debugvar ⇥ dump php variables in ‘pre’ tags for easy reading. this is a custom tab trigger which out puts

echo "<pre>"; print_r ($variable); die("</pre>");

in your code. create new tab trigger in bundle editor and add:

echo "<pre>"; print_r (${1:variable}); die("</pre>");

(thanks to Ryan Waggoner for this tip.)

Post your most useful in the comments. Thanks!

Comments (4)

  1. Very nice list my friend. TextMate is like a treasure trove of awesome features. The only bad part about it is remembering all the awesome things you can do with it!

    I will refer to this list many times.

  2. I think out of all the shortcuts I use in TextMate, the most popular one has to be the escape key. It cycles all the namespace on the current page. Suits lazy developers like me perfectly.

  3. Hold CMD, than you can select multiple areas in your document with the mouse and type at the same time. Perfect if you want to add classes to multiple elements at the same time.

Comments are closed.