nisus.com
https://www.nisus.com/forum/

Reversing Character
https://www.nisus.com/forum/viewtopic.php?f=17&t=4128
Page 1 of 1

Author:  bjast [ 2011-03-03 07:57:58 ]
Post subject:  Reversing Character

Has anyone ever developed a macro that reverses characters?

For example:

theer > there

whele > wheel

ohlding > holding

As I've gotten older I'm finding I'm making this kind of mistake more often.

Thansk

Author:  Kino [ 2011-03-03 10:23:33 ]
Post subject:  Re: Reversing Character

bjast wrote:
As I've gotten older I'm finding I'm making this kind of mistake more often.
Same hereĀ ;-( Or worse: it is getting harder and harder for me to detect typos.

In the past, a similar problem was discussed at:
http://www.nisus.com/forum/viewtopic.php?f=17&t=2659
To sum up, if you want to swap a character before the insertion point with a character after it, just hit control-t which is a built-in Cocoa keybinding, working in all Cocoa applications. However, if you want to reverse two characters before the insertion point, you need something else.

Here is yet another macro attempt for the latter case, the laziest oneĀ ;-)
Code:
Send Selector 'moveBackward:'
Send Selector 'transpose:'
As the macro above just call Cocoa actions via Send Selector command, it is easy to enable the same functionality in all Cocoa applications by putting a custom keybindings dictionary (DefaultKeyBinding.dict) in /Users/you/Library/KeyBindings/. Attached is a sample dictionary file. It is a text file you can edit, for example, in TextEdit.
Code:
{
   "^'" = (
      "moveBackward:",
      "transpose:"
   );
}
"^'" defines the key combination (control-') assigned to this functionality. To execute it by another key combination, just change "^'":
Code:
^: control key
$: shift key
@: command key
~: option key
For example, "^a" for control-a, "^$n" for control-shift-n.
Attachment:
DefaultKeyBinding.dict.zip [640 Bytes]
Downloaded 222 times

Page 1 of 1 All times are UTC - 8 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/