Defining a $PATH

Upcoming changes to OS X have caused us to make some changes in TextMate that have been causing some users to see a env: ruby18: No such file or directory error when running bundle items. This is caused by improper setup of the PATH variable, but lets go over what this variable does and how to correct the issue.

OS X comes with many command line tools that TextMate takes advantage of such as ruby, python, git, etc. To find these programs there is the environment variable PATH which is a list of paths that is used to find the required tools.

Note that while you may already have set the PATH variable for your shell (e.g. bash) it is not inherited in TextMate, as TextMate does not parse your shell setup scripts. For commands that require tools outside the default path list, like the LaTeX typeset command, we normally provide a list of common locations that TextMate should also search, so you normally should not need to change the PATH in TextMate.

To add to the PATH variable inside TextMate open Preferences and go to the Variables section and add a new item with the name of PATH. It is important that the value set augment the existing value instead of replacing it. To do this you should prefix the value with $PATH:. Example values for common uses:

MacPorts: $PATH:/opt/local/bin

Homebrew: $PATH:/usr/local/bin

This post relates to TextMate 2.0 only.

TextMate 2 Basics

Hilton Lipschitz has written a very nice introduction to TextMate 2 containing a lot of great tips and tricks for both the new and the experienced user.

2.0 Status and FAQ

The release of Mavericks has seen a new wave of users switching over to the alpha release so this is a good time to go over the common questions people are having:

Read the rest of the post »

TextMate 1.x under Mavericks

If you are using TextMate 2.0 then the following info does not apply to you.

Many of the bundle items in TextMate are written with ruby and were coded for version 1.8. With Mavericks Apple has updated the default version of ruby to 2.0. While we recommend everyone switch to 2.0 we realize that some people are hesitant to switch during a major project or similar.

If you wish to use TextMate 1.x on Mavericks you will need to tell TextMate to use ruby 1.8 for bundle items by putting the path to it first via the PATH variable.

Open Preferences from the TextMate menu and go to the Advanced section and select the Shell Variables tab. Click the + button to add a new variable named PATH with a value of:

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin

Make sure when copying this that there is no whitespace before or after the string and that it is on a single line.

If you wish to use another version of ruby for user scripts then set TM_RUBY to the path to your custom installed ruby. This is what will be used for Ruby → Run (⌘R), Ruby → Validate Syntax (⌃⇧V), and similar actions where user code is executed or scanned.

We previously sent out an email instructing 1.x users to update the shebang, those instructions are still valid, but we have since realized that the above is a simpler fix.

Nightly Build not Updating

For those that live on the cutting edge by watching the nightly builds of the 2.0 alpha you have been cutoff from automatic updates by an unfortunate bug introduced in a recent build (a9401). You can update by opening preferences (⌘,) and switching to the Software Update tab (⌘5). Here you will notice that the last check was a while ago and can manually check for an update by clicking "Check Now". After updating to a9409 or newer it will again check automatically for updates.

If you are using the "Normal Releases" option in this tab this bug does not affect you.

Apple Events & 10.8.2

Recently we have been getting reports of some issues with Transmit, QuickCursor and other applications that use Apple events to communicate with TextMate. Thanks to Brian Webster and Michael Tsai this has been tracked down to a bug in the appleeventsd process in 10.8.2, hopefully this will be fixed quickly by Apple.

A workaround for Transmit would be to mount the server as a hard drive and open the files from there as it would bypass the bug, this would also work in other file transfer programs that have this feature. You can get more information and alternative workarounds at the their respective posts linked above.

Nested Replacements

While updating the TextMate source to use ARC I needed to update the following code:

NSAutoreleasePool* pool = [NSAutoreleasePool new];
…
[pool drain];

To use the new autorelease blocks:

@autoreleasepool {
    …
}

Read the rest of the post »

Beyond Document Scopes

The way to specialize things in TextMate is via the venerable scope selector matched against the current scope.

TextMate 1 created the scope by parsing the document’s content using a language grammar. Though sometimes, more context information is needed than what can be provided by the document’s content, which is why TextMate 2 has extended the information stored in a scope.

Read the rest of the post »

Injection Grammars & Project Variables

I was recently dealing with issue #157 and wanted to store a reference in the source.

Of course this reference should be an underlined link and allow us to easily go to the online issue, yet I don’t want a 50 character long URL in the source, so how do we go about this?

Read the rest of the post »

Ars Technica Interview

Chris Foresman did this nice interview with me.

I hope it clears up some of the confusion that yesterday’s announcement may have left you with.

TextMate 2 at GitHub

Today I am happy to announce that you can find the source for TextMate 2 on GitHub.

I’ve always wanted to allow end-users to tinker with their environment, my ability to do this is what got me excited about programming in the first place, and it is why I created the bundles concept, but there are limits to how much a bundle can do, and with the still growing user base, I think the best move forward is to open source the program.

The choice of license is GPL 3. This is partly to avoid a closed source fork and partly because the hacker in me wants all software to be free (as in speech), so in a time where our platform vendor is taking steps to limit our freedom, this is my small attempt of countering such trend.

I am also a pragmatist and realize that parts of the TextMate code base is useful for other (non-free) applications, so I may later move to a less restrictive license, as is currently the case with the bundles. For now, please get in touch with us if there are subsets of the code base you wish to use for non-free software, and we might be able to work something out.

Anything related to the code base, including contributions, can be discussed at the textmate-dev list or #textmate on freenode.net. Pull requests can be sent via GitHub but if you plan to make larger changes, it might be good to discuss them first if you want to ensure that we are interested in accepting a pull request for such change or simply want advice on how to go about it.

Mountain Lions

As you start to upgrade your system to the latest cat from Cupertino we have created a page on the wiki as a place to keep track of any issues and notes about Mountain Lion and TextMate. We will be keeping this updated if any new issues are found.

You can bring up any issues or questions on the mailing list or you can contact us directly by email or on Twitter.

The Layout Engine

As in many other areas, TextMate 2's layout engine has received a bunch of improvements under the hood. It's sometimes hard to show these changes, at least until new features taking advantage of the changes begin to bubble up to the surface. Let's take a tour of some of those new features now, so I can show you just how dynamic what renders has become.

In this article will discuss:

  • The replacement of invisible characters
  • Per-line soft wrap and indented soft wrap
  • Dynamic font sizing
  • Folding pattern upgrades

    Read the rest of the post »

Using Find and Replace

Since the earliest word processors Find and Replace has been a standard feature expected by users editing almost any content. You can score extra points with the programming crowd if you support Regular Expressions, the swiss army knife mini-language of Find and Replace operations. Of course, TextMate 1 had both.

TextMate 2 adds some subtle refinements to this already strong collection of features.

In this article will discuss:

  • Keyboard usage of Find operations
  • New visual feedback provided for these operations
  • How to speed up your searches
  • Enhancements to the Find dialogs

    Read the rest of the post »

Leopards and Questions

Today we are pushing out a new nightly build for the 2.0 alpha that changes the minimum OS requirement to start requiring Snow Leopard, this change was made after checking the current statistics for 2.0:

10.8 2.0%
10.7 86.7%
10.6 11.1%
10.5 0.2%

With such a small percentage on 10.5 it makes sense to drop its support. Moving forward we may decide that requiring Lion will be a reasonable tradeoff as it provides many underlying benefits we could take advantage of. The usage statistics will be monitored to determine the feasibility of this move.

Also to help answer many of the more commonly asked questions we've put together a FAQ about 2.0.

Clever Completion

TextMate has always had completion and, as I've said before, it remains the best reason to wear out your (esc) key. The idea is simple and I bet you are already familiar with it, but, just to recap, if I had this Ruby code:

class BoundingBox
  def initialize(min_x, min_y, max_x, max_y)
    @min_x = min_x
    @min_y = min_y

    @max_x = max_x
    @max_y = max_y
  end
end

I could later use completion to finish off this line:

class BoundingBox
  def max_x=(x)
    fail "max_x must be > min_x" unless @m‸
    # ...
  end
end

If I push where my caret currently is (shown with above), TextMate will complete the variable reference to @max_y. It starts with @max_y, because that's the closest instance variable reference to my caret (from the bottom of initialize()), meaning it had a high chance to be what I was referring to. It's not really what I wanted though, so another press of cycles me to the second choice of @max_x. That is what I want, so I add > and another @m. Then I can complete until I get @min_x (four presses of or just one press of ⇧⎋ to go backwards, since it's the furthest reference from my caret).

In this article will discuss:

  • Reasons to use completion
  • Suffix completion
  • Prefix completion
  • Mid-word completion
  • Intelligent scoped completion

    Read the rest of the post »

Format Strings

TextMate 1 allowed you to use variable references in Snippets and even to supply defaults or simple replacements for them. TextMate 2 expands a lot on what you can do with variable references and where you can use them.

In this article we will discuss:

  • The syntax of TextMate 2's Format Strings
  • Where you can use them
  • The kinds of tricks these tools can help you accomplish

    Read the rest of the post »

mate and rmate

TextMate is and will always be a modern GUI application. However, developers are often forced to walk in two worlds using both GUI and command-line tools. TextMate has always bridged the gap between these environments with its trusty command-line sidekick: mate.

In TextMate 2, mate has learned some new tricks. A new partner-in-crime has also been introduced: rmate.

In this article will discuss:

Multiple Carets

One of the features user have continually requested for TextMate is the ability to insert multiple carets. Allan, TextMate's developer, was always a little resistant to the idea because it seemed to require the use of a mouse and he's not a mouse guy. Well, he caved. You can now use a mouse to throw down multiple carets and then edit away.

In this article will discuss:

  • Using multiple carets with the mouse
  • Changes to column selection
  • Using multiple carets with Find
  • Using multiple carets with Copy and Paste

    Read the rest of the post »

Whitespace Bundle

Mads Hartmann Jensen has written a bundle which takes advantage of a new injection feature of language grammars to highlight what can be considered improper whitespace. Highlighting both trailing whitespace and mixed tab/space indentation it can also be limited to just one or the other.

(This bundle will only work with the 2.0 alpha.)