[TxMt] Re: Inserting control character ...

Rob McBroom textmate at skurfer.com
Mon Sep 29 14:42:33 UTC 2008


On 2008-Sep-29, at 8:10 AM, Karl-Heinz Wild wrote:

> AFAIK it is possible the insert ^L to
> force the printer to start with a new
> page - in plain text files.
>
> But how can I insert this characters (control)
> with textmate.

I had a similar question about two years ago and didn't get much of an  
answer. I actually just solved this problem (for my purposes) last  
week. There are a few ways to represent things like ⌃L without  
literally typing it, but it really depends on what will be  
interpreting the character.

In my case (an init script for `tcsh`), I was able to replace all of  
the control characters with something like \033 for Escape, \007 for  
Bell, etc. To represent ⌃L, I could type \014. Finally, I can edit  
`.tcshrc` in TextMate. Sheesh.

I've been told that you can represent these characters in `bash` with  
something like $'\cL' (for ⌃L).

Finally, the Cocoa text system allows these characters to be typed by  
preceding them with ⌃Q. This works like ⌃V in the Terminal, so you  
would type ⌃Q⌃L to insert the Form feed. Unfortunately, this  
doesn't work in TextMate's editor window because ⌃Q is used for  
something else. It might work in TextMate's Find dialog or bundle  
editor (since the text controls there are closer to the default  
NSTextView), so you could type things there then copy them and paste  
them into the editor window, but that's a bit cumbersome. You could  
also type such things in TextEdit, then copy and paste back, but  
again, cumbersome. Another problem with using TextMate for this is  
that you can't really see what you've typed… er, I guess I should say  
"pasted". 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.

For a list of codes, see <http://en.wikipedia.org/wiki/ASCII>

-- 
Rob McBroom
<http://www.skurfer.com/>







More information about the textmate mailing list