Trick Your TextMate: The Series
Saturday December 17, 2005 / 24 CommentsI’ve been using TextMate for some time now. However, until recently, I hadn’t been using it enough to justify really getting to know it. After a bit of time exploring the new documentation, I have to say that it might be in the running for my favorite application of all time.
I wanted to take some time and share some of the features that get me hot and bothered. So this will be the first of several posts where we’ll explore all of the special powers of TextMate.
For a reference to the different keys, there is a section on terminology in the manual, but I’ve provided the following relevant key explanations for quick reference.
- ⌘ = Apple/Command
- ⌥ = Option
- ⌃ = Control
- ⇧ = Shift
Comment Toggle (⌘/)
This is feature is increasingly common among good text editors, but it’s a feature I can’t live without. By simply highlighting an area and pressing a simple two-key combination you can comment and uncomment a block of code. The best part is that it’s intelligent enough to know what kind of document you’re editing and use the appropriate commenting syntax.
Inserting Close Element (⌥⌘.)
Also context-sensitive, you can easily insert a closing element for a given tag. For example, you could turn…
<span class="example">Text
...into…
<span class="example">Text</span>
Easy Open & Closing HTML Tags (⌃<)
Straight from the documentation: This command will take the word just typed, and change it into <word></word> placing the caret in the middle. It will recognize those tags where a close tag is disallowed (like hr) and instead insert <word /> placing the caret after the tag. So, with a few keystrokes, we can turn…
div
...into…
<div></div>
Note: This key shortcut could also be thought of as (^⇧,)
Wrap Selection in HTML Tag (⌃⇧W)
Straight from the documentation: This will put <p>...</p> around the selection but allows you to overtype the p (and add arguments). After you are done, press tab to move the caret past the </p> tag. So, you could easily wrap the following selected text…
The quick fox jumped over the cow.
...with a paragraph tag as such…
<p>The quick fox jumped over the cow.</p>
...or use any other HTML tag you’d like.
Summary
These are just a few of the built-in shortcuts that I’ve found useful. Next time, we’ll dig into some of the more advanced features and how they can really start to save you serious time.
Featured Stuff - Resources: Wireframes & Page Description Diagrames
Omnigraffle and Visio versions of the wireframe templates and stencils I use on all of my projects. There’s even a few examples included for good measure. More about Wireframe & Page Description Diagram Stencils and Templates
I’ve been using Textmate for a while now, but didn’t know about some of these tricks.
Thanks! I look forward to the next episode… :)
MicheleArticles like this one are really a big advertisement for the discussed programs. I have heard of textmate, but I never used it. I will definitely give it a try now – especially since I am on a quest to find a replacement for windows-only TopStyle!
MichaelMicheal – I’m right there with you. I was absolutely in love with TopStyle. I didn’t think I’d ever be able to find a replacement on the Mac, but TextMate is definitely winning me over.
GarrettI think TextMate is great as well. It’s not a CSS tool the way TopStyle is, however, CSSEdit from MacRabbit is what I recommend. It actually has some features I wish TopStyle had.
Wade WinninghamI too am down with the TopStyle posse (autocomplete represent!), never thought anything could replace it.
Textmate is certainly more powerful, and after six or seven months, I honestly think it’s more fun to use.
One of my favorite features is the banner snippet that (I think) comes stock with recent builds. Type
Joseph Wainbannerhit tab, and start typing!TextMate has been number one on my list of favourite apps now for a while; it gets used every single day. At the office I kept my PowerBook around as a secondary machine, while I did a lot of work on my PC, but once I started to realize how powerful TextMate was I pulled out my mini VGA adapter and started using my PowerBook full-time. Now the PC sits off to the side, mostly being used to cross-platform test HTML code.
When I started using TextMate I felt a bit ripped off, because shortly after I licensed it an update made most of the language packs I was using incompatible. Luckily a month or so later a whole pile of updates started coming down and now not only are my language packs fixed, they are better than before and the interface has been beautifully streamlined.
Tim UruskiTextmate is also in the top five for me. There are still a few things that I’d like to see adjusted, but overall its a really great application with very active development.
Colin D. DevroeI, too, am in love with Textmate, a great little application.
That said, as more and more of my development work is done with RoR, I find myself leaning towards the use of the Rad Rails(.org). They’ve really done an admirable job of integrating support for Rails into Eclipse, and because it is open source, and doesn’t cost a dime, I’m thinking it’ll be a better solution long term.
I just wish I could configure RadRails user interface to be more similar to TextMate.
KyleI was initially a bit underwhelmed by TextMate – until I took the time to read the documentation. There are so many neat features like the ability to link a file or image simply by dragging it onto the page. Or type (say) ‘border’ and then tab to get a list of all of the different options. The Bundle Editor makes it really easy to customise the package – eg create a snippet that wraps the selection as a h1 headline – or a snippet that lets you set the heading level. Looking forward to the next instalment.
Andy MillerThanks for the shift+ctrl+w tip!!
I love textmate too.
Mattethanks, this type of information is sorely lacking on the macromates website. Not to mention that most people choose NOT to share their productivity secrets and snippets.
Obviously, the fact that these things sit in .plist files and not straight text must be discouraging for people who might be inclined to share their snippets etc. with the rest of the world.
gratefulComment toggle has one flaw that drives me crazy: if you 3-click to toggle a complete line, it puts the close comment on the following line. So if you want to un-comment the section, you have to manually select both lines, rather than just 3-clicking again.
SteveIt’s been nearly two months—are you planning to stretch this series out over the course of several years?
ClaytonSteve – You could call it an extended hiatus while I sort out some other things. I’m about to make the switch to be 100% Mac, so I’ll be using Textmate on a much more regular basis in the very near future and hope to make this much more regular. Sorry for the delay.
GarrettClayton—no sweat. I’ve been 100% Mac for several years now (Linux and Windows before that), and Textmate is definitely one of the best things to come along since I fully switched. Thanks much for the cool tips, and I’ll check your RSS feed for the next installment!
ClaytonHow’s it going?
ClaytonThings are about to get rolling again. SXSW took a lot of my free time, this weekend will be the return. ;)
I’ve got lots of plans and lots of energy. Things should be picking up around here very soon.
GarrettGreat article Garret, Textmate is a great program once you get into it and find out how it really works. I have put together a little cheat sheet for those using Textmate for Rails development, everyone can check it out at: Rails Cheat Sheet
Eric StewartThis is a very good article and I really love TextMate!
Jorge LaranjoGreat shortcuts…
Well I feel like I must be doing something wrong. I have bought TextMate but I don’t feel very comfortable using it. There are many things I am missing like tag hinting and such things. Maybe I am doing something wrong. But especially when you are coding in HTML and CSS I feel somewhat left out. Maybe your series can shed some light on my problems.
Timon RoyerI’m a little with Timon Royer on this
I also bought TextMate and have no regrets at all. However I must say with HTML and CSS it feels like I’m missing something. The biggest thing being the syntax highlighting. I have tried alot of themes and none do it well.
This is me coming from a XP + Dreamweaver background for example where HTML tags are distinguishable by their type.. eg: block, img and a elements are all different colors. In Textmate with most themes these are all the same color. Kind of makes it hard to browse through your code and pick out the different elements.
I’m thinking of making my own theme to get around this as I do love using textmate for rails, php and javascript.
Scott Mackenziejust grabbed myself a copy of Textmate…..seems great!
is there a way to change the colour of php delimiter tags < ? or < ?= or < ?php
In dreamweaver they stick out like a sore thumb, which I’ve grown used to!
MattI with that you could simply type and have it auto create the closing side. When would you NOT want a ?
I am used to that from IntelliJ IDEA, and I miss it in Textmate (which I think it is a great editor)
Dion AlmaerI created a textmate cheat sheet with a lot of nice shortcuts and tab triggers for the web designer using html, css, xml and php :
http://www.g-design.net/textmate.pdf
the pocketmod version
guntherfolding instructions
Comments are closed for this entry.