textmate

TextMate TODO tag syntax highlighting alvin January 12, 2019 - 5:17pm

As a brief note to self, I like the way the TODO tag is highlighted when using TextMate, so I dug around to see how it worked so I can make other words be highlighted the same way it is. The short answer is that in TextMate, click the Bundles menu, select Edit Bundles, then scroll down to select TODO near the bottom of the list, then Language Grammars and TODO. The last few steps are shown in the image.

Two more Textmate commands (capitalize, CSV to list) alvin September 11, 2016 - 10:43am

As a “note to self,” I wrote two more Textmate commands yesterday, one to capitalize each word in a selection of words, and another to convert a CSV list of words to a simple list. Here’s the source code for the Capitalize command:

#!/bin/sh

perl -ne 'print ucfirst $_'

The $_ portion of that Perl command isn’t required, but I include it as a reminder to myself about how Textmate commands and snippets work.

Here’s the source code for my Textmate command that uses the Unix tr command to convert a CSV list of words (such as a paragraph of comma-separated words) into a simple list of words:

#!/bin/sh

tr , "\n"

As you can see, those commands are fairly simple. If you know Unix/Linux and then know a little about how to write Textmate commands, you can usually get it to do what you want. I like that you can use any Mac/Unix programming language or tool to solve the problem at hand.

A custom TextMate command that uses ‘sed’ alvin August 10, 2016 - 5:19pm

In this post I share the contents of a custom TextMate command I just created that uses pandoc and sed to convert markdown content in the TextMate editor to a “pretty printer” version of HTML:

#!/bin/sh

PATH=$PATH:/usr/local/bin

# note: 'sed -E' gives you the advanced regex's

# use pandoc to convert from markdown to html,
# then use sed to clean up the resulting html
pandoc -f markdown -t html |\
sed -Ee "/<p|<h2|<h3|<h4|<aside|<div|<ul|<ol/i\\
\\"

You can try to use a command like tidy to clean the HTML, but the version of tidy I have does not know about HTML5 tags. The TextMate Markdown plugin also doesn’t work the way I want it. Besides that, I’m trying to learn more about writing TextMate commands anyway.

As an important note, when you set this up as a TextMate command and then run it, it will convert the TextMate editor contents from markdown to HTML.

(In a related note, serenity.de is also a good resource for TextMate command and bundle documentation.)

In summary, this code shows:

* How to execute a Unix shell command from TextMate
* Specifically, how to execute a sed command from TextMate
* How to use modern regular expressions with sed (the -E option)
* How to search for multiple regex search patterns with sed

How to insert text with a custom TextMate Bundle snippet alvin July 4, 2016 - 2:06pm

As a quick note to self, I just created a TextMate Bundle snippet to insert some text at the current cursor position. Using TextMate 2.0.x, I did it with the following steps. I’ll go through these steps quickly as I’m just writing this for myself:

A custom TextMate 2 bundle to underline the current line alvin May 6, 2016 - 10:31pm

I just created a TextMate 2 bundle to underline the current line, and this image shows how I created that bundle. The dashed-line will be the same length as the line the cursor is currently on (the current line). I do this a lot when I use TextMate to write notes and even Markdown text, so I wanted a little script/bundle like this.

FWIW, the result of this bundle/command is that I can have the cursor be on a line like “Hello, world,” as shown below, press [Command][u], and end up with this:

Hello, world
------------
TextMate - converting tabs to spaces (or not) alvin August 13, 2011 - 6:07pm

I finally dug into a problem with TextMate that has been driving me crazy. I always have the TextMate "soft tabs" feature enabled, and want two spaces wherever there was a tab. However, it turns out TextMate doesn't really do what I expect here. Instead of automatically converting tabs to spaces, you have to take an extra step to make this work.

Assume you've just opened an existing document. To convert the tabs in the document to spaces (soft tabs):

How to move the TextMate project drawer from one side to the other

I don't know how TextMate decides where it's going to put the project drawer (the drawer that slides out when you open a directory or project instead of opening a file), but sometimes the drawer comes out on the left when I want it on the right, and other times it comes out on the right when I want it on the left.

Unfortunately it's not at all obvious how you're supposed to move the project drawer from one side to the other, but after digging through the help documentation I finally found it.

TextMate product review alvin October 23, 2007 - 2:16pm

As general-purpose text editors go, TextMate on Mac OS X is probably one of the best I've ever used. Favorite features are the built-in spell-checking, solid macro support, and a clean UI that stays out of the way. It also offers syntax highlighting for many different languages out of the box, which is nice when because I work in HTML, Java, and Ruby a lot. Smart tabs generally work very well also.