If you find yourself in a position to have your code reviewed, do it. Wise words from Luke Woodward.
From the “Kindred Spirits” pattern chapter in Apprenticeship Patterns:
Your community’s health can be measured in the way to reacts to new ideas. Does it embrace the idea after vigorous debate and experimentation? Or does it quickly reject the idea and the person who proposed it? Today’s dissident is tomorrow’s leader, and one of the most valuable services you can provide to your community is defending it against those who believe that marching in lockstep is the price of membership.
I love this challenge—it’s got me thinking a lot about how I approach new ideas, both when I bring them to my community or team and when I’m faced with new ideas from other people.
I am sometimes going with the flow in order to be liked and get along with everyone? Do I reject things out of hand because I don’t like the idea or the person? And do I question everything with a healthy dose of dissidence?
Andrew Nacin’s article The qualities of a great WordPress contributor is required reading for WordPress contributors of all shapes, sizes, skills, and ambitions.
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