TextMate News

Anything vaguely related to TextMate and macOS.

TextMate 1.5.6

Version 1.5.6 was released last weekend and while my main focus is on 2.0 (which for the records only has a stated ETA of after Leopard) a lot is still happening with TextMate bundles, so here’s a few highlights.

Edit in TextMate

While not a bundle, a popular TextMate companion is the Edit in TextMate input manager. It allows you to call TextMate from any editable Cocoa text view, edit the text, and then have it sent back when you save and close the TextMate window.

This input manager is old news and I have mentioned it before. A recent addition is that it now works with WebKit’s custom text fields used by Safari 3β.

The way this is implemented is by asking the HTML view for the DOM and then use some methods on the DOMHTMLTextAreaElement to get and set the text (thanks to Rachael of the Omni Group for suggesting this approach). Unfortunately there is (to my knowledge) no way to know which text area is actually the active one (well… except for in OmniWeb) so a heuristic is unfortunately necessary.

The input manager is open source so improvements in form of patches are more than welcome :)

Objective-C Bundle

Joachim Mårtensson has done awesome work with this bundle improving the indispensable bracket matcher so that it now has a 99.9% accuracy. He also added completion for all the standard Cocoa frameworks.

While the code completion is not always able to find the type of expressions, it does have a few features that goes beyond normal code completion. I strongly recommend reading the help file included in the bundle (reached via Bundles → Objective-C → Help) but here’s a few examples:

  • Type - windowW inside an @implementation@end block and then press ⌥⎋ to get a pop-up listing all the windowWill delegate methods. Select the one you’re about to implement and have TM insert the proper boilerplate with the correct argument types.

  • Type NSUT followed by ⌥⎋ when filling in the last argument for stringWithContentsOfFile:encoding: to have TM insert the proper symbolic name for the UTF-8 encoding.

  • Type NSWin when providing the name of the notification you want to add an observer to and press ⌥⎋ to see the list of all the NSWindow notifications.

Joachim also did a screencast demonstrating many of these features. Here’s a direct link.

SQL Bundle

The SQL bundle received a major overhaul done by Ciarán Walsh, also responsible for all the recent improvements in the PHP bundle, which deserve a screencast and a blog post of its own.

In addition to documentation lookups and the language grammar, the bundle has a new database browser for which connections are setup using a GUI (Bundles → SQL → Configure) rather than relying on environment variables (passwords are kept in the key chain).

The bundle has a command to execute current line or selection as an SQL query. Coupled with intelligent snippets for your frequent queries, this feature is extremely useful and I often do snippets for what I would write a script for in the past. For example refunding a license key is refund⇥ followed by ⌃⇧Q (when present, serial number is taken from the clipboard).

Since I was keen on getting this updated bundle into the 1.5.6 release, I did rush it a bit, and the bundle has received a few updates mainly related to PostgreSQL.

To see the list of changes since the release (assuming you have svn installed, if not see Installing Subversion) you can run:

svn log -r7715:HEAD \

If you want to update the bundle I recommend replacing the bundle inside TextMate.app. This way your checkout will be replaced with the next update of TM and you won’t be left with an outdated SQL bundle that eclipse the default one (which would be the case if you checkout to /Library or ~/Library and forget to remove it again or svn up the checkout).

Assuming you installed TextMate in /Applications and already have svn then this is done with these lines (in a bash compatible shell):

export LC_CTYPE=en_US.UTF-8
cd /Applications/TextMate.app/Contents/SharedSupport/Bundles
rm -rf SQL.tmbundle
svn co http://svn.textmate.org/trunk/Bundles/SQL.tmbundle

TODO Bundle

Stanley Rost (Soryu) is behind the improvements in this bundle. These include nicer output which is incrementally updated with status about which folders are being scanned. TODO markers are now configured using a GUI (reachable via Bundles → TODO → Preferences) so you no longer need to edit the source code of the command to alter the markers.

The bundle also has a neat snippet: type todo⇥ in whatever language you work and a TODO list is inserted wrapped in block comment characters appropriate for your current language with the caret waiting for your first TODO.

categories General


I’ve loved the “edit in TextMate” feature from the moment I discovered it, and I was disappointed when I installed the latest Leopard preview release and found out that—true to their word—Apple has disabled the use of InputManagers, so this feature no longer works.

Were you aware of this change coming down the pipe? Do you know of some way to make this work with Leopard? I know Leopard is still out on the horizon, and it doesn’t do much good to start pulling out hair over this yet—just curious if you think there will likely be some way to get this feature back.

The SQL Browser looks really interesting. However, it prompts me for my database password every single time I click on anything in the browser. I’m browsing a mySQL4 database on localhost. Any suggestions?

17 July 2007

by david s

The SQL Browser never asks me for my password, and then authentication fails when it tries to connect!

Is there anyone specifically maintaining the Ruby/Rails bundles? If I work on them, where do I post patches etc?

The SQL Browser works fine for me, except that it always prompts for a password every time it needs to perform a query.

David: have you got the latest version of the SQL Bundle from SVN as described in the post?

When I get back to my mac, I am going to have to try these things out. Looks Great!

John: I can’t talk about Leopard stuff because I am under an NDA. There are some comments about Apple’s plans here (basically saying Apple is undecided about the final outcome but that they are long-term deprecated). At the same time Leopard is also introducing code-signing…

Dr Nic: James Edward Gray is the maintainer of the Ruby bundle and sort of the maintainer of the Rails bundle (shared with Duane Johnson). But contributions are definitely welcomed! See how to contribute for info.

Mark/David: It would be great if one of you gouts could join the #textmate channel at http://freenode.net so that we can troubleshoot the issue.

a welcome thread for shameless self-promotion!

i’m planning to release a plugin for development of actionscript 2 with textmate. i’ve put up some screenshots for the curious. you see them here: http://nesium.com/blog/flashmate/i would be glad if someone could actually test this, before i release it, so if you’re interested, drop me a line at nesium-gmail-com.

cheers, marc

Marc: Wow! That looks like quite a plug-in!

You should send a note to the mailing list, or I can do it for you, if you don’t want to subscribe. But lots of AS2 users there.

hi allan. i’m very glad you like it! so i’ll take your word and post it to the mailing list :) (i’m already a subscriber, but didn’t post anything yet)

Is anyone ever going to fix the TODO bundle so it stops defaulting to the root folder of projects? One of my projects includes symlinks to two different folders in /var, which means when I try to use the bundle it searches through my entire /var folder which essentially makes it useless.

20 July 2007

by Jacob Rus

Tom: just leaving a comment on this blog post is very unlikely to get someone to change the bundle for you. If you can´t figure out how to alter it yourself (I doubt it´s that complex, though to be honest I haven´t looked at the code), you should figure out exactly how it should work instead, and what needs to be changed, and then hop onto the TM IRC channel, or send a message to the mailing list, to get that discussion going.

I do love TextMate!

03 November 2008

by Uğur Özyılmazel

hi, SQL bundle has a small problem, i tried to fix but i coudnt. when i browse my rows, turkish chars are broken. tables are utf-8 and utf8_turkish_ci. i checked connectors and other stuff but i am not a ruby coder. can anyone help me out to fix?

03 November 2008

by Uğur Özyılmazel

well, i fixed it… fix the db_browser_lib.rb under /Applications/TextMate.app/Contents/SharedSupport/Bundles/SQL.tmbundle/Support/bin/

@@connector.query(“SET NAMES ‘utf8’;”) if encoding[“server”] != ‘latin1’


@@connector.query(“SET NAMES ‘utf8’;”)

Uğur Özyılmazel: I think that “fix” implies your server is reporting latin1 as its encoding. If you control the server, you should set it to use utf-8.

I have the following in /etc/my.cnf (on the server):

default-character-set = utf8

default-character-set = utf8

You can test what your server reports by opening an SQL session and run:

SHOW VARIABLES LIKE 'character_set_%';

With MySQL it can be a little confusion because the server, database, table, connection, client, etc. can all have different encodings.

23 April 2009

by Uğur Özyılmazel

Allan Odgaard: well, all the .conf variables are utf8…

mysql> show variables like '%character%';
| Variable_name | Value |
| character_set_client | utf8 | 
| character_set_connection | utf8 | 
| character_set_database | utf8 | 
| character_set_filesystem | binary | 
| character_set_results | utf8 | 
| character_set_server | utf8 | 
| character_set_system | utf8 | 
| character_sets_dir | /usr/share/mysql/charsets/ | 
8 rows in set (0.00 sec)

still turkish chars are broken… i did it again in my way… the only thing that maybe some ruby guys here can help us if this line of code is ok?

  encoding = @@connector.query('SELECT @@character_set_database AS server').fetch_hash
  encoding = {:server => 'utf8'}

when i query ‘SELECT @@character_set_database AS server’ i get utf8 as result..

its like this if/else thing is not working…