Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Add 'twiddle characters' support to Cocoa apps Apps
There have been several previous hints regarding keybindings. This one will explain how you can activate the BBEdit-like 'twiddle' command, which transposes two adjacent characters. Since 'transpose' is an action which may be bound to keystrokes, it is possible to add the following line to your user's Library -> KeyBindings -> DefaultKeyBinding.dict file and get the twiddle feature in Cocoa applications:
  "^`" = ("moveBackward:", "transpose:"); /* bbedit twiddle */
Since transpose acts on the characters to the left and right of the cursor, the moveBackward command allows one to place the cursor to the right of the characters to be transposed. Pressing Control-` will then transpose them and leave the cursor in its initial position (transpose moves the cursor forward).

There's a nice reference to the keybinding key syntax in a KeyBinding article on CocoaDev.com, and a list of actions that may be bound to keystrokes can be found in Apple's NSResponder documentation.

[robg adds: I didn't have either the folder or the file noted above. However, simply creating them and then adding the command worked perfectly -- TextEdit now twiddles the characters as described. If this stuff interests you, you can see some of the previous hints on keybindings with this search or this search -- there will be some overlap between the two, but they should cover all the keybinding hints.]
    •    
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)
 
[8,264 views]  

Add 'twiddle characters' support to Cocoa apps | 12 comments | Create New Account
Click here to return to the 'Add 'twiddle characters' support to Cocoa apps' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
The default key for this is Ctrl-T.
Authored by: Djehuti on Oct 28, '04 10:48:49AM

Most text entry components support Emacs-like key bindings. As such, the keystroke Ctrl-T generally transposes adjacent characters in most text entry boxes, including web forms (lkie tihs one) and in TextEdit.



[ Reply to This | # ]
The default key for this is Ctrl-T.
Authored by: Eravau on Nov 03, '04 11:39:47AM
Does not work in Firefox, Entourage, Word, Excel, Photoshop, Illustrator, GoLive, InDesign, DreamWeaver, or BEdit. Basically it doesn't seem to work in any of the applications I use on a regular basis that would have any significant amount of text.

Does the control-t actually work in any non-Apple product?

[ Reply to This | # ]
Cocoa is the key
Authored by: Rainy Day on Jan 24, '09 02:05:36PM

That's because the apps you cite are not Cocoa. This feature – and many more – come for free on any Cocoa app. Legacy carbon code won't normally support it (unless the software engineers make an extra effort, which generally won't be the case). All the software you cite is legacy carbon code. Worse yet, they're all designed with cross-platform code-bases (which usually means a diminished/inferior user experience relative to natively designed apps).

To answer your question: Yes, there are non-Apple apps which support this. Any app built on Cocoa, to be specific. Lots of shareware falls into this category. Most commercial apps won't, because most are legacy carbon apps. With Apple finally dropping support for carbon apps in Snow Leopard, this situation is likely to change in the future, so stay tuned.



[ Reply to This | # ]
Add 'twiddle characters' support to Cocoa apps
Authored by: mistersquid on Oct 28, '04 11:04:22AM

On my computer, Ctrl-` cycles through all open windows in all programs (Alt-tab equivalent). I do not believe I have modifed anything to achieve this functionality.

Given that one commenter has mentioned that Ctrl-T provides transpose functionality in many programs, one might not want to bind this transpose function to Ctrl-`.



[ Reply to This | # ]
Add 'twiddle characters' support to Cocoa apps
Authored by: avarame on Oct 28, '04 07:48:33PM

Doesn't work like that on my computer. Ctrl-` just beeps.



[ Reply to This | # ]
Add 'twiddle characters' support to Cocoa apps
Authored by: Han Solo on Oct 28, '04 11:22:00PM

Yes, that's because on a stock 10.3.x install, the "Rotate windows" feature is mapped to Command-`, not Control-`. "mistersquid" has either remapped the keys in System Preferences > Keyboard & Mouse > Keyboard Shortcuts (yes, it's there... scroll down a bit), or has mistaken the Command and Control keys. (Mentioning "alt-tab" -- which does not exist on a Mac: Command-Tab cycles programs -- may indicate "mistersquid" is a Windoze refugee, coming from a land that knows not of the Command key. Not that there's anything wrong with that -- the more Mac users, the merrier.)



[ Reply to This | # ]
And you are who?
Authored by: mistersquid on Oct 29, '04 01:44:02PM

I'm sorry, but you get the "bozo" award for referring to me (or anyone, including Windows users) as a "Windoze refugee." I have been using Apple machines since 1982, Macintosh since 1992, have never owned a windows machine, and know very well the difference between Comamnd and Ctrl, thank you very much.

It turns out that in System Preferences > Keyboard & Mouse > Keyboard Shortcuts > Keyboard Navigation, one of the items is "Focus on Window (active) or next window". I don't recall changing this from Ctrl-F4 (default) to Ctrl-`, but there it is.

Anyhow, this option is the Windows equivalent of Alt-Tab. It cycles through ALL open (non-minimzed) windows in ALL (unhidden) programs.

Rather than dismissing people who know more than just a single platform (e.g. Mac users who also have worked with Windows machines), you might consider that what seems to be incorrect is actually a product of your ignorance rather than someone else's.



[ Reply to This | # ]
Hey, Rob...
Authored by: jecwobble on Oct 28, '04 01:14:08PM
You didn't have the folder or file, huh? Did you forget you created this hint many moons ago?

[ Reply to This | # ]
Hey, Rob...
Authored by: robg on Oct 29, '04 11:02:07AM
Hehe -- probably didn't recreate it after upgrading to 10.2 or 10.3 :). Wow, that is an oldie...

-rob.

[ Reply to This | # ]
Add 'twiddle characters' support to Cocoa apps
Authored by: DavidRavenMoon on Oct 29, '04 11:03:47AM

Control-T works here as well to transpose two adjacent characters ... so I don't see the need for this hint... but I also didn't know about Control-T either! Also, I use Control-` all the time to rotate windows.

---
--
G4/466, 1 GB, Mac OS X 10.3.5



[ Reply to This | # ]
Add 'twiddle characters' support to Cocoa apps
Authored by: atheken on Oct 29, '04 02:59:37PM

no you don't, you use command-` (see preceding thread) :-)

---
//Andrew Theken



[ Reply to This | # ]
Add 'twiddle characters' support to Cocoa apps
Authored by: DavidRavenMoon on Oct 29, '04 03:09:18PM

Oops... you are correct! :-/

---
--
G4/466, 1 GB, Mac OS X 10.3.5



[ Reply to This | # ]