One of the (many) cool features of textmate is that it makes it very easy to pass text to other programs. You can highlight a piece of text and pass it to any command you can access from the command line and get the results back. So you can pass text to a unix command or a perl script or a ruby script - basically this means you can extend textmate using whatever command or programming language you want!
As an example, I just exported a list of albums and artists from my itunes library. The export took about 5 minutes and when it was finished the albums were listed in random order. I had expected them to be sorted by artist. To sort the list I can just highlight the text, click “Text->Filter through command” and enter sort as the command. This lets me filter the text through the unix sort command and replace it with the resulting text.
Say you want to change a piece of text to all upper-case letters (This is a contrived example for illustration purposes - there is already a command to do this in textmate). You can highlight the text and filter it through the command ruby -e 'puts $stdin.read.upcase'. This just executes a single line of ruby code to read the text that is passed in through stdin and convert it to uppercase.
If you find yourself filtering through a command repeatedly then it is easy to create a textmate command to do the task. So textmate you the full power of unix in a text editor.
I still mainly use "vi" but Textmate is quickly becoming my favourite editor.
However this textmate feature isn't new. All the old UNIX editors like vi & emacs have done these shell escapes for years. For eg. with vi u just need to prefix the UNIX command with a !
To sort a lines 5 to 10 of a file in vi is just ...
5,10!sortTo put whole file thru your ruby command is.....
%!ruby -e 'puts $stdin.read.upcase'/Baz/
Thanks for the vi tips. I've had been using emacs before textmate. I realize you can pipe to the shell in most editors. But I think that textmate makes it much easier to save these as commands or snippets if you find yourself doing them repeatedly or regularly chaining sequences of commands together. So you can easily use the shell or ruby or python or whatever to extend the functionality of the editor - no need to learn a new language like elisp.
The way I look at it (and imho)... "vi" is the best UNIX terminal editor and Textmate is the best Mac OSX editor!
So there is a bit of horses for courses going on.
I spend a lot of my time jumping from Linux to UNIX to MacOSX and back again in endless loops! I just wish I could spend more time doing dev stuff on my Mac and so get to use Textmate a lot more ;-(
/Baz/
Post new comment