TextMate News

Anything vaguely related to TextMate and macOS.

Beta 17 notes

Beta 17 of 1.1 was released yesterday, and the major new cool thing is the new snippet capabilities. I already dedicated an entire post about snippets, but as a bonus I recorded a movie showing some intelligent snippets.

The movie shows 5 snippets in action.

  1. head inserts a source header (I rarely create sources from templates, but instead just use snippets), nothing really special about this snippet other than using niutil to insert the current users full name.
  2. m inserts an Objective-C method. What’s neat about this snippet is that return nil; disappears when the return type is changed to void.
  3. log inserts a log statement and, as can be seen the second time it’s used, when the format string contains an (extra) % character, it will make room for an extra argument (which one can tab to).
  4. ⌃⇧B inserts a banner with editable text, and adjusts the size accordingly. This snippet uses the $TM_COMMENT_START/END variables, so it also works with Python, XML a.s.o. using appropriate comment characters.
  5. objacc is the last snippet, and it inserts a get and set method for Objective-C. Two nice features shown is that a) it will correctly uppercase first letter of the attribute name for the get method and b) when putting a space in front of the asterisk in the attribute type, it binds this character to the variable in the getter method (i.e. removing a space on the left side of the asterisk).

And that’s probably enough about snippets for this time. Coincidentally some of the new snippet features were not supposed to happen before 1.3, but I was so be smitten with ANTLR that I decided to redo the snippet parser now rather than later, which takes me to the next b17 enhancement.

Scope selectors

I have previously written about scopes. Since then I have decided to refer to scopes (entered in the GUI to restrict something to a fragment of the document) as scope selectors, which is only natural since these are inspired by CSS selectors, although this change hasn’t made it to the interface yet.

I wrote in tips and tricks about how one can override functionality, for certain parts of a source, by using scopes, but it has a shortcoming. Let’s for example say we want the # key in Ruby strings to insert #{$0} (as a snippet). We create the snippet, set the key to # and scope to source.ruby string. Unfortunately if we press # inside embedded code in a string, we get the expansion there as well.

Starting with b17 it’s possible to perform boolean operations on scope selectors and take the asymmetric difference between two scope selectors. So in the example above we want our custom action on # to expand in source.ruby string but we don’t want it for string source (embedded code in strings). For this we can now set the scope to:

(source.ruby string) - (string source)

I added the parentheses for clarity, they are not necessary (since - has lowest precedence).

Go to previous file

There have been requests for a way to jump between open buffers (in addition to ⌘1-⌘9 and ⌥⌘ arrow left/right/up), in particular, a consistent way to get to the last file worked upon. Until now TextMate only offered the file chooser (old movie), but Jonathan Ragan-Kelley suggested that this file chooser could also take the role of jumping to previous buffer(s), by keeping the list sorted based on last visit (when there is no filter string).

This turned out to be much more useful than I had initially imagined. So now there is a quick way to jump between two arbitrary files in a project: ⌘T followed by return.

categories General


02 September 2005

by Andreas Wahlin

if only each tab could be it's own window with it's own positions yet regain it's place in the project scope, we could switch between different buffers as easily as we switch between open windows in the same app

Above grumbling said, I really like the new snippet functons AND I really really like the new handling of tabs from things copied from clipboard, I frequently find myself having to go up to the beginning of a paste and hit tab a few times, that seems to be at an end now!

02 September 2005

by Anonymous

the new GUI for the execution screen is very nice but it has one problem, if the output of your program is HTML, it renders the html (probally because the screen is rendered with html). How can I avoid this?

Anonymous: I assume you refer to the new tm-ruby or PyMate to run Ruby and Python scripts? At least tm-ruby should be updated to properly escape the output.

“So now there is a quick way to jump between two arbitrary files in a project: ⌘T followed by return.”

Rock on.

03 September 2005

by Jeczallik

Love the new snippets! I would really love to have a feature where I can save all the open windows in a new ‘loose pages’ project. I currently have 30 textmate windows open, and have to reboot thanks to Safari updating.

I will not ‘loose my place’ and have to manually open all the windows again; I would much rather be able to either save my position or save all the open windows into a project, where my place is saved and can be restored to simply by opening Textmate.

Keep up the good work!

03 September 2005

by Mark Patterson

I’ve just started using the latest version. The html and css don’t show syntax highlighting, but js files do. Do I have to get the bundles with svn?

Mark: No, HTML and CSS should work out-of-the-box.

Check that the status bar shows HTML as language, and maybe try to change theme in Preferences / Fonts & Colors, some themes are probably better than others, when it comes to coloring HTML.

04 September 2005

by Mark Patterson

The languges indicated in the status bar are HTML (Basic) and CSS. I tried all the themes, and all I got was unhighlighted text. None of the syntax elements seem to be recognized. However, it works for JaveScript. Any ideas?

04 September 2005

by domenico carbotta

note to anonymous: pymate does proper html escaping from the day it was born :)

05 September 2005

by Mark Patterson

Thanks for the advice (via e-mail) Allan. I deleted the bundles for html and css in ~/Library/Application Support/TextMate/Bundles, and the syntax highlighting came back. For good measure I then did the svn download. It comes up highlighted slower than before I did that svn downoad, but I think it’s still faster than last time I did the svn download, a few months back.

Thank you, Allan for a great app! Not sure if you are aware of this bug, and if this is the right place to report a bug, but here goes:

The “Go to symbol” menu command (under the navigation menu, shift-command-T), produces a function pop-up dialog box. However, when you click on the list, it seems to be consistently choosing a function 10 lines above what you clicked on and the scrollbar for the dialog box doesn’t seem to be active (not clickable).

Are you aware of this?


Sorry but how did you do the banner snippet. Can you please show that snippet code, thanks.

08 September 2005

by chongqing xiao

This movie looks great.

One unrelated question, will texmate handle chinese?
I tried to enter chinese but it won’t work.


Sorry chong, currently the international support in TM is shady.

Thanks allan.

Any idea if this is on the to do list?
I am hoping to use TextMate for ruby on rails development but I need chinese support.

10 September 2005

by Allan Jardine

Thanks for the latest release. Excellent little bit of software! I was hoping b17 would fix the biggest niggle I’m having TextMate: when the files are altered in the finder, all of the folders in a project collapse. When working a couple of directories deep its a bit irritating. Any chance we’ll see this fixed in future?

Allan (a different one)

chong: eventually it’ll be improved, but it’s probably post 1.3.

The different Allan: yes, this will all be fixed in 1.2, and I’m currently trying to wrap up things to get 1.1 out as final :)

I second Jeczallik’s wish for a way of gathering “loose” pages into a project, or having this functionality as a preference (open new files as tabs, kind of like TextWrangler does it…) Thanks for a great application!

I love the updates in b17. I’d been using a much older beta (b11, IRC) so the update was much appreciated.

A while back I asked about being able to set tab sizes to something other than the current options (2,3,4, and 8). You said that an “Other” option would go into the Tab Size menu into a later beta; another beta had the ability to set tab size as an option in a bundle (I assume that was implemented in lieu of the former option).

But now I can’t figure out how to use the “tabSize” option to set the tab size in the current beta, and of course there’s no “Other” option in the Tab Size menu.

What are my options?

Jay: sorry for keeping you waiting – I started a branch of the source where I moved tab size (and some other stuff) to the status bar, which had the Other option, but that branch is currently just a branch.

As for using the bundle editor to set a special tab size, make a new Preferences item and just let it be e.g.: { tabSize = 7; } and you have your odd tab size. You can set the scope to e.g. source.ruby if you want this only for a particular file type.

I’ve created the Preferences item, and placed it in the bundle I’m creating (in a Preferences folder, like other bundles I’ve looked at) but it’s still using my default tab size.

Am I missing something? Do the uuids for the preference and the syntax have to match?

Never mind, I figured it out. happydance

One last question: how do I change text stylings for syntax matches? Right now, all of my keyword.* matches show up the same; I’d like to be able to differentiate them a bit. From reading some of the info on here, it looks like it’s basically a CSS-style formatting, but how/where do I place my definitions?

Jay: the UUID is unimportant, the scope OTOH is not.

But I’m not sure I understand what you’re saying: did you manually create the preferences item on disk?

The way you should create it is to go to the Bundle Editor (via the window menu), create e.g. a custom bundle, which you select (to have your custom stuff in its own bundle), and then select New Preferences Item from the add (+) button, and then paste the { tabSize = n; } in there.

While you can do the equivalent by creating the preferences file on disk, it needs to contain more than just the { tabSize = n; } part, which is why you should do this from the BE.

Jay: Go to Preferences / Fonts & Colors, here you can add new settings for specific keywords (scopes). See e.g. Introduction to scopes for more details about the concepts.

I’d pretty much figured out what you’d posted about creating Preferences items in the Bundle Editor.

Re: Fonts & Colors, my eye somehow glossed right over that part of the Preferences dialog.

Thanks again for your help. :)

There were some really usefull info (for me!) in the release notes of the b17, but I can’t find the releaseNotes file! It was about selecting some text, press some buttons and move the text around using the arrow keys. Maybe it was a just a cocoa standard, but I can’t find the keycombo to activate that behaviour…

Could we have the releasenotes (back) in the .dmg package, please? Or posted somewhere?

Loving textmate more and more for every day…


Ok, ignore that. Help menu -> ReleasNotes. Slapping myself. Sorry.

Ok, found the notes, read’em all, but no info about that press-some-keys-and-move-selected-text around. Damn. Was I dreaming? Could anyone help here?


Try the Text menu under Move Selection. The keys are ⌃⌘ plus arrow keys.

So right… [Feeling ashamed].