Replicating TextMate: Comment Banner Plugin for Coda

Published 7 years 9 months ago on December 1, 2008 — 4 min read

Throughout the life of Monday By Noon, I’ve been quite public about my choice of operating system. Originally I was a Windows user, from there I switched to Linux and finally made my way to OS X. I haven’t looked back, and I’m consistently impressed with the quality of applications available, not only for Web design, but general use as well.

Choice of text editor is a very personal thing for any developer. I’ve tried nearly every editor under the sun, just to make sure I wasn’t missing out on anything. Over the past year or so, I’ve wobbled back and forth between TextMate and Coda. TextMate is brutally useful, and Coda is terribly beautiful and functional. Time after time I’d return to TextMate simply because of the elaborate bundles, especially the snippet implementation. Coda’s editor just didn’t cut it when it came down to the timesaving techniques TextMate has spoiled with me.

Then came Coda 1.6. Coda now supports a full range of plugin functionality, along with a stunning plugin creator. I was instantly thrilled, dying to give Coda a fighting chance against TextMate. Since the debut of 1.6, some really great third party plugins have been published, and I’m very excited about the potential of very elaborate plugins down the line.

Writing a Coda plugin

I’ve never been one to get very detailed with plugin development, mostly because any plugin I wanted to write had already been done (and done well). With Coda plugins being brand new, there are plenty of plugins to write; I thought I’d give it a shot.

Writing a Coda plugin is terribly easy. It’s a matter of downloading the plugin creator, choosing from a number of languages, and publishing your plugin. If you’ve never built a plugin before, I’d definitely suggest playing around with Panic’s implementation with Coda, it’s a very satisfying experience.

Comment banner plugin for Coda

The functionality behind the plugin I decided to write by no surprise is rooted in TextMate. I’ve become a huge fan of the comment banner snippet in TextMate. It gave me a ridiculously fast way of inserting comment banners, allowing me to further segment some of my larger CSS documents, and I’ve even started documenting my source documents and JavaScript using comment banners. If you’re not familiar with comment banners, check out a quick screencast I put together:

Unfortunately, in its current state, my plugin is nowhere near as advanced as the TextMate implementation. In TextMate, you can simply trigger the snippet and type your comment as you go. My plugin instead uses an existing line of text and transforms that into a comment banner. Once I take a closer look at the Coda plugin architecture, I’d like to completely duplicate the TextMate implementation.

Another feature that’s currently incomplete is the syntax mode detection. I’ve only had time to implement a few of the document types I find myself editing most often. Once I look into the comment syntax of all the modes supported by Coda, I’ll make additions to make the plugin that much more comprehensive. Of course, if your syntax mode of choice is not supported (there’s a good chance it may not be) you can post a comment below and let me know about it, I’ll make updates as soon as possible.

Additionally, the syntax detection that does take place only looks at the extension of the file in which you’re working. For example, the plugin doesn’t know you’re editing a JavaScript block inside an HTML document.

You can trigger the plugin by typing your intended comment (single line of text) and choosing Plug-ins > Comment Banner, or simply use the key command from TextMate; Control + Shift + B.

If you’re a Coda user, I hope you find this plugin useful. If you’ve got any feedback at all please take a moment and post in the comment thread, and stay tuned for updates!

Download Comment Banner

Version 0.6.1
December 17, 2008 – Implemented possible fix for ‘Undefined variable’ error messages
Version 0.6
December 12, 2008 – Added Coda comment bookmark syntax (Suggested by Jason)
Version 0.5.1
December 5, 2008 – Added support for JSP
Version 0.5
December 1, 2008 – Initial release

Copyright © 2006—2016 Jonathan Christopher