Why do you want to type control codes directly? It's a lot safer to use escape sequences.

Bash even has a string quote form $'string', which supports escapes, and an escape \cx which stands for the control-x character. This means you can represent the ^[ character as $'\c['.

On Nov 29, 2006, at 4:17 PM, Jacob Rus wrote:

Rob McBroom wrote:

For shell init scripts and various other purposes, I'd like to be able to "type" characters like ⌃[ or ⌃G. You know, the kind of thing you would precede with ⌃V in the Terminal. It seems that Cocoa has a key binding for this (NSQuotedKeystrokeBinding, which is ⌃Q by default), but it is used for another purpose in Textmate. Has the functionality been remapped or do I need to try to define it for Textmate myself? It doesn't seem to be set…

I'm pretty sure TextMate's text control doesn't support that, but you can try.

    rob@kendra ~> defaults read com.macromates.Textmate NSQuotedKeystrokeBinding

    2006-11-29 14:47:10.910 defaults[6713]

    The domain/default pair of (com.macromates.Textmate, NSQuotedKeystrokeBinding) does not exist

On a related note, I'd like to be able to "see" these characters as well, or perhaps toggle them of and on (with ⌥⌘I ideally). Texmate is better than most Cocoa apps, as it seems to display a space in place of such characters instead of nothing at all, but I'd like to know what that space represents. Has anyone tried enabling [NSTextShowsControlCharacters][] in Textmate? I'm guessing there would be undesired side-effects.

Did you try showing invisibles?  I believe these show up as different from spaces or tabs, but I don't remember exactly what they look like.

In any case, you should be able to copy/paste them into a textmate control from another window, or make a command to insert them, something that takes the previous letter ("[" for instance), and turns it into the control sequence ("⌃[").

Kevin Ballard