TextWrangler Codeless Language Module

I have always been using text files to manage my todo lists but only recently been enlightened of the Todo.txt concept. This post will teach you how to write and deploy a markup definition file for TextWrangler on Mac so it will automatically highlight your Todo.txt like this:

sample-to-do

Tools I use:

Notes on the tools:

The concept of the Todo.txt is very simple. There are only 3 rules to follow:

  • Priority e.g. (A), (B), (C) and I added (U) for undecided
  • Project e.g. +Health
  • Context e.g. @home

I won’t elaborate too much here because you can learn more by visiting this page from the Todo.txt website or click here to download a sample file.

To make sure that TextWrangler highlights my Todo list as I wish, I wrote a .plist (property list file) for my installation of TextWrangler on my Mac. What is TextWrangler? It’s a text editor that offers much more functionality than Notepad. It’s a Mac equivalent to Notepad++ – my favourite text editor on Windows OS. I would suggest any programmer to use TextWrangler.

ToDoCodelessLanguageModule.plist

My .plist reference to the TextWrangler Codeless Language Modules. The following is the contents of my ToDoCodelessLanguageModule.plist





BBEditDocumentType
CodelessLanguageModule
BBLMLanguageDisplayName
To Do
BBLMLanguageCode
ToDo
BBLMColorsSyntax

BBLMKeywordList

(A)
(B)
(C)
(U)

BBLMSuffixMap


BBLMLanguageSuffix
*.todo


BBLMLanguageSuffix
.todo


Language Features

Comment Pattern

String Pattern
@w+s|+w+s
Identifier and Keyword Character Class
A-Za-z0-9_?!()


The code above is open source so feel free to use it at your own risk. If you are going to repost it else where, I hope that you would give credit to me.

Usage:

The ToDoCodelessLanguageModule.plist should be saved to folder: ~/Library/Application Support/TextWrangler/Language Modules

  • Priorities will be highlighted as blue
  • Projects and contexts will be highlighted as red
  • 2 types of comments: line comments starts with a # symbol; block comments are enclosed in /* … */
  • A completed task will be highlighted the same colour as a comment
  • To mark a task completed and ensure the highlighting was applied, you must follow the format: X YYYY-MM-DD (see screenshot at the beginning of this post for more details)

To test it, start a new file in TextWrangler and save it as a .todo file. For example:

save-file

Close the file then open it again, try to type “(A) Call Mom @Phone +Family”, the automatic highlighting should start as you type.

You can also verify it by checking that “To Do” appears on the language bar as a user defined language. For example:

todo-as-language

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s