17 Feb 2006

Journal TextMate plugin

About a month ago, I mentioned that I'd made some customisations to TextMate to help me with the plain text journal file I keep to jot things down on a day-to-day basis, and a couple of people expressed an interest in me releasing a bundle with the modifications. It almost didn't seem worth doing because what I'd mostly done was to add minor things to the Markdown bundle. However, I thought that people might be able to add to it and improve it, so I decided to bundle it up.

Language and snippets

The language section of the Journal bundle includes the Markdown bundle, so that you can use the Markdown format in your Journal files. I've also just copied over a few of the useful snippets and commands, like the excellent snippets for adding unordered or numbered list items. You just hit the enter key at the end of a line (not return), and the snippet inserts either a * or increments the appropriate number depending on whether you're in an ordered or unordered list. I added a similar snippet ('Add unordered todo item') which uses Shift-Enter to add * [], placing the cursor between the square brackets for the first tab position, and outside it for the second. It's handy if you want an ad-hoc todo list to keep track of what you have to do today---put an 'X' in the square brackets to mark as done.

There's also the snippet to make the entry itself (as I described in the my previous article), which is inserted with the tab trigger 'dts'. I also modified Alan's excellent suggestion to paste the clipboard into a new entry (tab trigger: dtsp).

Macro

There's already a built-in command to toggle all of the entries open or closed (Option-Command-0), but I wanted to be able to toggle a single entry closed when my cursor was somewhere between the date header and the closing ***. So I made a macro called 'Toggle folding on this block' which is triggered with Control-Command-F1.

Commands

image

The Preview in Browser command is just copied straight over from the Markdown bundle, but I've modified the Preview command to pretty up the output a bit, as you can see in the image to the left. Tags are marked up with a coloured background, and entries outlined in colour with a prominent heading. The CSS styles are in the Preview command, so if you open up the Bundle Editor you can tweak the styles to your taste.

I think that's about it---get the Journal bundle here. To use it, place it in your ~/Library/Application Support/TextMate/Bundles folder, then make sure that your journal text files have the Journal language selected (use the drop-down language menu at the bottom of the window). If you want to get syntax highlighting, you'll need to visit Preferences then Fonts & Colors and make new elements in the panel below. For example, if you want to make the [tag] a different colour, make a new element, call it Keyword tag (or whatever you like), style it the way you want, and then set the Scope Selector to markup.tg.markdown.

  1. 1

    A sample text file would be a really easy way to document the usage of this plugin. How about Insert Snippet-> Journal-> Sample Entries ?----- Thank you very much for sharing... for the completely css impaired, would you share the goodlooking html template?

    by tfserna @ 24/02/2006 7:03 pm • Permalink

  • 2

    Thanks for sharing! I look forward to trying it out.

    by mkb @ 10/03/2006 4:03 am • Permalink

  • 3

    I modified an existing "find in document" command to give me a slightly specialized "find in journal":http://www.schussman.com/article/1316/textmate-modified-find-in-journal-command command that you may be interested in. It searches (clumsily) for bracketed keywords and outputs a list with short excerpts for easy finding. I've found it pretty handy over the last couple of days -- I hope it's useful to other users of the journal bundle.

    by alan @ 13/06/2006 4:07 am • Permalink

  • 4

    alan: Oh, that's really nice! Just what I needed! -----

    by bsag @ 14/06/2006 5:07 pm • Permalink