switching adjacent letters (I'm a bad typist...)
Posted: 2007-11-14 10:45:06
This is inelegant, my sense is there should be a way to do it more concisely. But the following seems to work consistently and the "if" seems to catch start-of-document failures.
I gave it a name (Reverse Characters.nwm) and assigned a simple and meaningful keystroke to it (⌘R).
$pplace=Selection Location
$pplace -= 1
if $pplace<2
exit
else
Set Selection $pplace, 1
end
:Edit:Cut:Cut
$pplace -= 1
Set Selection Location $pplace
:Edit:Paste:Paste
$pplace += 2
Set Selection Location $pplace
Note that I tried to Find/Replace, but it goes one extra character backwards at the end of a line, which would often be the case in actual use. Maybe someone can figure out an elegant way so that it finds the previous character consistently and doesn't need a lot of checks for failure points?
Here's what didn't work (I tried many variations, it didn't seem robust).
Find and Replace '(.)(.)', '\2\1', 'bE'
Select end
I gave it a name (Reverse Characters.nwm) and assigned a simple and meaningful keystroke to it (⌘R).
$pplace=Selection Location
$pplace -= 1
if $pplace<2
exit
else
Set Selection $pplace, 1
end
:Edit:Cut:Cut
$pplace -= 1
Set Selection Location $pplace
:Edit:Paste:Paste
$pplace += 2
Set Selection Location $pplace
Note that I tried to Find/Replace, but it goes one extra character backwards at the end of a line, which would often be the case in actual use. Maybe someone can figure out an elegant way so that it finds the previous character consistently and doesn't need a lot of checks for failure points?
Here's what didn't work (I tried many variations, it didn't seem robust).
Find and Replace '(.)(.)', '\2\1', 'bE'
Select end