Mac Text Editors

One of the most baffling gaps in Mac third-party software is programming-oriented text editors with autocomplete. Now, obviously there’s XCode, vim, and emacs (which, being free, are all something of a problem for would-be competitors), and a bunch of cross-platform tools like Eclipse and Komodo, but XCode is really oriented towards Cocoa development and is kind of like using Microsoft Word to edit a shopping list, while the others are all non-Mac-like (and kind of suck anyway).

The Mac heavyweight text-editing champs — BBEdit and TextMate — have many great features, but don’t do autocompletion very well or at all, respectively. (There’s some kind of third-party hack add on for TextMate, but you need to compile it yourself and few seem to be able to get it working.) A lot of Unity developers were using PCs or Virtual Windows boxes to run Visual Studio just because it has an autocompleting text editor that doesn’t suck — that’s how bad it was. (Now that Unity runs on Windows their lives have gotten much easier, which is a pretty sad statement.)

Before you scream at me about how, say, Subethaedit has some kind of autocomplete support, or mention Coda (which has OK autocomplete support) or Espresso (which may one day have halfway decent extensible autocomplete support but right now is a work-in-progress), go and try Visual Studio or, if you’re allergic to Windows how about Realbasic. Realbasic‘s built-in text editor has autocomplete that doesn’t suck, e.g. it recognizes context, knows about intrinsic language constructs as well as library functions and the stuff you’ve declared, and doesn’t incorrectly complete stuff you need to fix constantly or fail┬áto offer “function” when I type in “fun” in a .js file.

I will say this: TextMate’s macro facility is truly awesome (you can type swi->TAB and get a switch statement template, and then tab through the bits you need to change, almost like a context-sensitive-in-place-dialog-box), if this were paired with a proper autocomplete system (like RealBasic’s) it would be the best I’ve seen and then some — maybe 2.0 will have this — but right now the situation on the Mac remains pretty dismal.

  • Andrew Barry

    I’m not sure of the exact reasons for this, though I will say that getting fast text rendering using the ‘recommended’ APIs has been an uphill battle under OSX. It seems that every major release has had some developer statement about how text rendering is now awesomely faster. Maybe hardware has also caught up? Shrug.

    Also if you are using Cocoa, the NSTextView control is actually pretty good to get a basic text editor up and going, and though while it has some degree of autocompletion support (though I must admit to not having delved too deeply into it), it’s still well short of giving as seamless an experience as in some of those other environments you mention. Xcode probably has the strongest example of wrangling NSTextView, and it often just feels clumsy (e.g. the rendering of warnings and errors).

    These two examples are relevant because someone needing a text editor component as part of their program can either:
    * just use NSTextView and accept its shortcomings (but welcome its strengths such as multiscript support)
    * go entirely back to the drawing board and have to get over the “it’s really hard to just drawing a text string quickly” hump before they even get to thinking about doing stuff like autocomplete

    Of course on the Windows/Linux side they have to start from scratch anyway, but at least they can draw text strings quickly.

  • I think Espresso has taken the approach of trying to work with NSTextView, but so far the results are uneven (some languages work better than others for intrinsic stuff while others work better for library functions, and nothing will autocomplete for user functions).

    I think that Visual Studio, XCode, and Realbasic rely on having the entire compiler chain on hand to lexically analyze the code and build symbol tables, etc. which allows smarter autocompletion (I imagine emacs and vim use similar tricks).

    I’d settle for an editor that autocompleted based on a static library PLUS things that were obviously symbols in your code PLUS had some prioritization clue (e.g. function should appear about function_exists in the autocomplete list) PLUS TextMate’s macros. I guess the best hope for this is TextMate since its macros are stupendously nicer than anything I’ve seen, and almost make up for its lack of autocomplete.