Unless I’m using Objective-C, which is fantastically self-documenting, I often like to add comments to parameters to remind me of what they do. For example:
imagecopy($image, $frame, ($x=max($width-$this->topRightCap[kCapWidth], $this->topLeftCap[kCapWidth])), // Destination x 0, // Destination y $x, // Source x 0, // Source y min($this->topRightCap[kCapWidth], $width-$this->topLeftCap[kCapWidth]), // Source width $this->topRightCap[kCapHeight]); // Source height
The only thing is, it looks terrible and is very hard to read. I usually carefully insert spaces before the comments so they line up, but that’s really hard to maintain.
I use Textmate, and found an ‘Align Assignments’ script by Chris Poirier which applies very nice formatting to a block of assignments.
Some trivial modifications resulted in a similar script to align comments. Hit Ctrl-Option-Command-/, and:
imagecopy($image, $frame, ($x=max($width-$this->topRightCap[kCapWidth], $this->topLeftCap[kCapWidth])), // Destination x 0, // Destination y $x, // Source x 0, // Source y min($this->topRightCap[kCapWidth], $width-$this->topLeftCap[kCapWidth]), // Source width $this->topRightCap[kCapHeight]); // Source height
Here it is:



Textmate: ‘git diff’ in FileMerge
I found myself wanting to pick through some changes I made under a git repository recently, discarding some and adapting others. The FileMerge utility that comes with the Mac OS X Developer Tools is great for this purpose, but in TextMate, there’s currently no way to compare uncommitted changes in a git repository using FileMerge.
Now there is!
View Uncommitted Changes in FileMerge.tmCommand.zip
Double click to install it in Textmate; it appears under the ‘Git’ bundle. I suggest you then select the ‘Git’ bundle group header, and drag this command (‘View Uncommitted Changes in FileMerge‘) up to the top of the menu list on the right, so it’s accessible via Control-Shift-G, 1.
It’s based on filemerge.tmbundle.