Rob McBroom wrote:
All of these characters are invisible and the "Show  
Invisibles" command represents them all with the same diamond  
character. I hate to say it, but if you need to deal with literal  
control characters in a file, you should probably use something in the  
Terminal, like Vim.
  

I'm kind of surprised TextMate doesn't already have a way to do this, and I'm really surprised that you can't use octal escape sequences such as \001 as a replacement expression in the Find/Replace dialog. But you can work around it...

For general conversions, here's a simple command:

    /usr/bin/tr 'a-zA-Z' '\001-\032\001-\032'

Use the Bundle Editor to make a new command, input = "Selected Text" or "Character", output = "Replace Selected Text". Type and select a letter and run that command to turn it into the equivalent control character.

If you just have a specific few characters you often need to insert it might be easier to make them into tab triggers.  For example, if you need to insert a control-X create a tab trigger like:

    echo 'x' | /usr/bin/tr 'a-zA-Z' '\001-\032\001-\032'

And assign it a key sequence you find convenient.

(And, hopefully TM2 will have some way to assign unique symbols to different control characters when "show invisibles" is on!)

--
Steve King
Sr. Software Engineer
Arbor Networks
+1 734 821 1461
www.arbornetworks.com