TextMate for Projects with Both HTML and Code

I don't know how many find themselves in the the situation of working on a single project that involves HTML, CSS and Objective-C, but I do. I feel it's worth pointing out how TextMate is invaluable for this sort of thing.

Here's a screenshot of my TextMate project for the Cocoa graphics tutorial at Cocoa Dev Central:

TextMate with HTML


Here's the same project with the CSS file in focus:

TextMate with CSS


If I want to compare two versions of the CSS file, I select the files in the project and choose Diff > Select Files in Project Drawer:

TextMate with Diff


We already know TextMate is a great HTML and CSS editor. I make changes and hit Command-R to have the page reloaded in Safari. But the magic happens when I switch over to the Objective-C class file that the tutorial discusses:

TextMate with Objective-C


What happened here is I opened the MyView.m class file — just the file — in TextMate, and hit Command-R. I use the same key sequence that I use to reload an HTML file, but this time the context is Objective-C, so the behavior is different. In this case, TextMate runs the application that the MyView class is associated with.

In fact, if I press Command-B, TextMate will build the project using the Xcode build system:

TextMate with Xcode Build


TextMate does this without me adding the Xcode file to the TextMate project. In fact, Xcode isn't even running. I can't tell you how helpful it is to not have to bounce back and forth between Xcode and a separate editor. I can stay in TextMate and even use the same key sequences. TextMate works out what to do given the current context.
Design Element
TextMate for Projects with Both HTML and Code
Posted Nov 6, 2006 — 11 comments below




 

Mark Grimes — Nov 06, 06 2300

...and TextMate recently supports Cocoa method completion / lookup... satisfying one of the two major gripes (? and ? dbl-click) coming from many productive Xcoders.

Mark Grimes — Nov 06, 06 2301

Site doesn't seem to like the glyphs for Command and Option (utf-8?) -- however I'm sure I was understood even without the proper glyphs.

Jamie Kirkpatrick — Nov 06, 06 2303

I'd be really interested to see an article from someone about using TextMate as a replacement for Xcode (or Xcode as an editor at least) in a more general sense...

There must be people doing this....what is it like? what are the pros and cons? Discuss ;)

Dan Price — Nov 06, 06 2304

I'd be really interested to see an article from someone about using TextMate as a replacement for Xcode (or Xcode as an editor at least) in a more general sense...

Defo. From what you've been saying, I must check this out. Is that the default code-coloring or your personal preference. Sweet.

Questions:
- If you drag a .h file to IB, does it treat it like a .h file from XCode?
- Can you reference resources (NIBs, graphics) from TextMate and launch/view them in the editor?
- When you run code, do you get a console/output window?
- What about the debugger? Not that I use it much.
- Can you terminate hung executables from within TextMate?

Cheers.

Scott Stevenson — Nov 06, 06 2305 Scotty the Leopard

Is that the default code-coloring or your personal preference

It's called Blackboard. Not the default, but one of a number of built-in themes. I bounce between a few depending on my mood, but this is one of my favorites.

If you drag a .h file to IB, does it treat it like a .h file from XCode?

Yes.

Can you reference resources (NIBs, graphics) from TextMate and launch/view them in the editor?

If you double-click a NIB package it opens in IB. If you unfold the package, you can look at the actual contained files as text versions of key-value pairs. If you double-click a graphics file, it opens it via Launch Services.

When you run code, do you get a console/output window?

I use the Console app. I believe this is the only way but I could be wrong.

What about the debugger? Not that I use it much.

As far as I can tell, you need to use Xcode for that. I'm actually not sure how such a thing would work in TextMate since it's a text editor.

Can you terminate hung executables from within TextMate?

Not that I know of. Just force quit.

TextMate is not intended to be a complete replacement for Xcode. That would be a huge mess. It's a replacement (or complement) for the Xcode editor. It has a few missing features relative to Xcode, but also some tremendous benefits.

David Cairns — Nov 06, 06 2306

I've been using TextMate since the Summer. I'm not too good at saving money, and I was using TM on three different computers almost every day, so i figured, "Sure, $50 for a text editor is reasonable!" Sarcasm aside, I have been very happy with this decision.
I tend to keep Xcode open while I'm working on my code in TM, and, though I build using TextMate, Linker errors don't show up yet. This is pretty much my only gripe about the product. Also, I wish there was some way to bring back that scary Halloween icon.

Aside: I have never been involved in a flame war before, but I heard that people that use Blackboard are inferior at writing Cocoa versus people that use Espresso Libre*.

-- david
*Note that I learned bindings from a tutorial Scott wrote.

Scott Stevenson — Nov 06, 06 2309 Scotty the Leopard

Also, I wish there was some way to bring back that scary Halloween icon.

Halloween Icon

I heard that people that use Blackboard are inferior at writing Cocoa versus people that use Espresso Libre

I heard that Espresso Libre people don't even use tab triggers. They just type it all out by hand.

Panagiotis Atmatzidis — Nov 06, 06 2311

Dan Price said : - When you run code, do you get a console/output window?

It's possible and it's very extensible, especially if you have basic bash (and probably ruby) programming experience.

As a starter programmer with no previous experience in programming, I decided to buy a book and start with Objective C. The files I work on, are .m files. I didn't like the idea to open the console and supply the command line every time I had to compile & run a single file in order to understand if there were semantic or syntax errors. So here is what I did and works perfectly. I'm sure you can create bundles to do almost everything.

Galen D. W. — Nov 06, 06 2314

One other thing I love about TextMate: When you click on the "action" button (that little gear at the bottom), the item closest to your mouse is the type you're working with. For example, if you're working in a CSS file, you click on the action button and CSS is right there, not up at the top of the screen. I know it's not much, but it just goes to show how refined this app is.

<i>I heard that Espresso Libre people don't even use tab triggers. They just type it all out by hand</i>

Wait a minute. I use Espresso Libre, and I don't use tab triggers as much as I'd like to. I usually just forget after doing things The Hard Way for so long. ;)

Galen D. W. — Nov 06, 06 2315

Heh heh. Whoops. BB tags. Right.

Panagiotis Atmatzidis — Nov 07, 06 2321

Galen D. W. said:
I know it's not much, but it just goes to show how refined this app is.

Exactly! Most of the things TextMate is able to do flow in a natural way and it makes everything easier. I think of TextMate as one of the smartest applications ever made with simplicity in mind.

I admire for the same reason applications such as QuickSilver, VoodooPad a different kind of editor. There are other smart apps around, the weird thing is that most (if not all) of these applications are for MacOSX only :-)




 

Comments Temporarily Disabled

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





Copyright © Scott Stevenson 2004-2015