If you find yourself in a position to have your code reviewed, do it. Wise words from Luke Woodward.
Forge is a free command-line toolkit for bootstrapping and developing WordPress themes in a tidy environment using front-end languages like Sass, LESS, and CoffeeScript.
During the early development process of this year’s default theme for WordPress, the Twenty Twelve team—Drew Strojny and myself—used Github and Forge to build the theme (view the archived source).
In summary: Forge is too restrictive for general theme develpoment.
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