Matt Wiebe linked up a piece of required CSS reading from Nicholas Gallagher.
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:
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.
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 (
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
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
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
An update on my Dvorak learning experience, one year later. I switched one year ago, over Thanksgiving break.
When I started, my goal was to get to 40 WPM to feel comfortable getting my daily work done. With that goal accomplished, I ran drills continually with the MasterKey software, and watched my milestones go by: 50, 60, 70.
Today my average speed in drills—with accuracy—is 75 WPM, very close to what I was with QWERTY before the switch. What I lost in time and energy learning the new layout I’ve gained back in bunches with touch-typing skills and typing confidence. I’ve learned to use the top number row (and its related symbols) much better now, and rarely look down.
I don’t have efficiency stats to compare before and after, but my confidence and speed in typing make me feel great about this decision.
Verdict: typing is fun. Just like any tool I use, I’m aiming to master it—and I’ve found it’s more fun when done with confidence and expertise. Every day is stronger, faster, better.
Quick update on my progress typing with the Dvorak layout (see original post first if you missed it). I am now averaging 65 WPM in my drills, though I am a bit slower in real usage.
I first considered getting the droolicious Model S Ultimate Silent Keyboard from Das Keyboard, but since it’s a bit pricy I opted instead to use the stickers as a low-cost first step.
Today I changed the keyboard settings on my Mac to use “Dvorak” instead of “Dvorak – Qwerty ⌘” to force myself to relearn my keyboard shortcuts.
So far, so great.
To work smarter and faster at my craft, I took the plunge and switched to the Dvorak Simplified Keyboard.
At our Automattic company meetup in September Matt handed out paper copies of The Dvorak Zine, a fun, well-written treatise on why Dvorak is better than the traditional QWERTY keyboard layout. I read it on the plane ride home, played with Dvorak settings on my laptop a bit, and vowed to make the switch during my next extended time off work.
Here is the timeline from my switch.
1. September 16th, 2010: Read The Dvorak Zine.
2. November 22nd, 2010: Started practicing with Master Key during a week off from work.
3. December 3rd, 2010: Removed QWERTY from my keyboard settings.
4. December 9th, 2010: Finished Master Key Dvorak drills (set to 40 WPM goal).
For fun, here are some stats as of December 9th, 2010 based on my Master Key drill results.
My tips and recommendations: Get Master Key, add Dvorak to your keyboard settings, and practice. Then remove QWERTY from your keyboard settings and use Dvorak for everything you type. Pace yourself and be patient. Keep practicing and don’t give up.
For more on Dvorak, see Matt’s 2003 classic: On the Dvorak Keyboard Layout.
Update December 14, 2010: My goal with learning Dvorak is to get faster and more efficient at typing than I was with QWERTY—with which I type 75 WPM with accuracy. The 40 WPM mentioned in the timeline was during drills used to learn Dvorak; that speed is not the end goal.
Update December 28, 2010: This week I passed the Master Key drills again with the speed goal set at 50 WPM. My average speed is approaching 60 WPM.
Update January 17, 2011: Now averaging 65 WPM, see notes in Still Learning Dvorak.
Update November 22, 2011: An update on my Dvorak learning experience, one year later: Dvorak Redux.