Hi all
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.
Karl-Heinz
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 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!)