Objective-C and PHP Additions in TextMate 1368

The newest build of TextMate adds completion-related improvements for Objective-C and PHP. Here's a quick glance at what they are and how to use them.

Objective-C Additions

The Objective-C bundle can now autocomplete all of the important class names inside messaging brackets.

Objective-C Class Completion


A minor inconvenience is that there are two commands that do very similar things. Esc will autocomplete from a short list of the most popular classes — string, array, dictionary, and mutable versions of each. Hitting escape multiple times will run through these options very quickly. This is a good tool whenever you quickly need basic storage.

Autocompletion with Option-Esc consults a vast list of classes and presents the results in a popup list, but only works inside square brackets. This command will offer both NSArray and NSArrayController, for example, whereas the quick completion would offer only NSArray.

Also, you might remember that TextMate 1360 added easy object instantiation by typing "NS" and hitting tab, which creates a new instance for most of the obvious classes in the main frameworks. Not to mention build 1310 added method completion, which is activated by the same Option-Esc sequence as the class names.

An incredibly valuable addition here would be for the new class completion command to work in a broader scope, so that it could be combined with the "NS" tab trigger (hint, hint Joachim).

If all of this is too much to remember, just use Option-Esc when inside square brackets to autocomplete class or method names. Use Esc to complete symbols that you type (variable names and such).

PHP Additions

PHP has picked up the function popup lists as well, using the same magic Option-Esc sequence.

PHP Function Completion


You can get much of the same functionality by just hitting Esc to run through various options. Unsurprisingly, this works much the same as the Objective-C bundle.

Particularly interesting in this build are the documentation-related additions to the PHP bundle. The first is Option-F1 to get a tooltip with a signature and short description of the current function.

PHP Function Description


The cursor must be outside of the parenthesis for this to work, by the way. Also, you can bring up the live documentation page for a function with Control-H:

PHP Function Documentation


As always, you need to activate Cutting Edge updates in Preferences → Software Update in order to get the newest builds.
Design Element
Objective-C and PHP Additions in TextMate 1368
Posted Mar 4, 2007 — 12 comments below




 

Joe Goh — Mar 04, 07 3673

The only obstacle that prevented me from using TextMate for Objective-C is the lack of a popup list for autocompleted items, and only using TextMate for HTML/CSS. With this major gripe gone, i'm going to use TextMate for nearly all text editing tasks. :-)

Thanks for the heads-up Scott.

StuFF mc — Mar 05, 07 3674

Coming from Visual Studio.NET I really appreciate the use of TAB, and really depreciate the use of ESC, which is not at all on a good place on the keyboard, and is on some keyboards too small (like on my MacBook). One thing that keeps me using SubEthaEdit is also that TextMate want le me "Save on the Server"...

Scott Stevenson — Mar 05, 07 3675 Scotty the Leopard

@StuFF mc: and really depreciate the use of ESC, which is not at all on a good place on the keyboard
The Option-Esc sequence can be changed to whatever you want in the Bundle Editor. The completion command is in the Objective-C bundle and is called "Cocoa Context".

TextMate want le me "Save on the Server"
I'm not sure which FTP client you use, but I use Transmit's external editor support, which works just fine with TextMate. I also use the "DockSend File"command quite a bit, which is in TextMate's Transmit bundle. I guess there is interest in TextMate having built-in FTP/SFTP support, but I think this works pretty well.

Matt Mower — Mar 05, 07 3676

If you use MacFuse and sshfs then editing on remote file systems becomes just as convenient as local ones.

Joachim Mrtensson — Mar 05, 07 3677

I am not certain how useful it would be to use the NS-snippet with class completion since many(most?) of the cocoa classes do not have factory methods named according to the 'remove NS and lowercase'- method employed by the NSSnippet (it is just a regexp using TextMate's mirroring technique).

Completing class names outside of brackets will soon be added, as well as some other completion goodies.

Henrik N — Mar 05, 07 3678

Actually, I believe this revision was pushed as a "Minor Update" (the default value), so no need for "Cutting-Edge" this time.

Kelan — Mar 05, 07 3679

I noticed yesterday that TextMate now has a "run log" that shows up in the bottom of the "Build Results" window when you press cmd-R, so you don't have to open up Console.app to see your NSLog()s anymore. I'm not sure when this was added (I can't find any reference to it in the release notes), but I was definitely happy to see it.

David Wareing — Mar 05, 07 3680

The text editor decision recently became a lot tougher with SubEtha's inclusion of Tabbed windows, but TextMate's project support is a real win. TextMate, however, does have some issues:

- the symbols popup menu should be moved back up to the top of the window where it belongs. There are numerous things wrong with the placement, but the most grievous is the need to engage in precision clicking else the Dock will grab you. No response from developer on this one.

- there is nasty search-and-replace bug, at least using the (third party) Lua module, which the developer hasn't been able to reproduce yet. Also, its project-wide search results needs to be implemented in a split window view.

- the app needs to remember project state, for the drawer. It's great being able to open my entire project, but a bit tedious to have to go and then manually open up the file hierarchy.

Overall though, a great app, and recommended.

thegoldenaura — Mar 05, 07 3681

TextMate Rocks!!! :)
By the way, really nice TM Theme. I supose you have done it, because i can not find it in the included themes list.
Thanks

Joachim Mrtensson — Mar 05, 07 3682

@David: A quicker way to access the symbol popup in TextMate is to use Shift-Command-T,

Since no one has mentioned it (It was not mentioned in the release notes). I thought I tell you that in this release the insert matching bracket command has been completely reworked. It now consults a list of known Cocoa methods before inserting the opening bracket.

And finally a trick for people who have problems reading Objective-C syntax. Since October it has been possible to color the Objective-C method names: even multipart ones. Set the "support.function.any-method" scope to the color of your choice in Fonts & Colors in Preferences.

But the possibilities does not end there! (Uses best infomercial voice). If you want the method-names to show up in different color depending on how deeply nested they are create another item with the scope set to "meta.bracketed.objc meta.bracketed.objc support.function.any-method" (yes the meta part should go twice), pick another color and the Objective-C syntax has now become easier/harder to read :). If you want to allow coloring for even deeper nested methods create another item with three "meta.bracketed.objc" in the scope selector, repeat if you want to color even deeper nested methods.

David Wareing — Mar 05, 07 3683

Joachim, thanks for that. That does help take some of the pain away.

Cheers.

Scott Stevenson — Mar 06, 07 3685 Scotty the Leopard

@Kelan: I noticed yesterday that TextMate now has a "run log" that shows up in the bottom of the "Build Results" window when you press cmd-R
Yup, I just noticed that too. I'd bet it was added in this release since I use that feature quite a bit.

@thegoldenaura: By the way, really nice TM Theme. I supose you have done it, because i can not find it in the included themes list
The theme is Monokai.




 

Comments Temporarily Disabled

I had to temporarily disable comments due to spam. I'll re-enable them soon.





Copyright © Scott Stevenson 2004-2015