Welcome Guest.   Make a donation to an author on the site October 24, 2014, 07:40:14 PM  *

Please login or register.
Or did you miss your validation email?


Login with username and password (forgot your password?)
Why not become a lifetime supporting member of the site with a one-time donation of any amount? Your donation entitles you to a ton of additional benefits, including access to exclusive discounts and downloads, the ability to enter monthly free software drawings, and a single non-expiring license key for all of our programs.


You must sign up here before you can post and access some areas of the site. Registration is totally free and confidential.
 
The N.A.N.Y. Challenge 2013! Download dozens of custom programs!
   
   Forum Home   Thread Marks Chat! Downloads Search Login Register  
Pages: [1]   Go Down
  Reply  |  New Topic  |  Print  
Author Topic: Free Windows Text Editor that transposes last 2 characters typed on Control-t ??  (Read 2703 times)
MilesAhead
Member
**
Posts: 4,947



View Profile WWW Give some DonationCredits to this forum member
« on: July 23, 2010, 12:25:47 PM »

Subject line says it.  I'm looking for a Free Windows Text Editor that transposes last 2 characters typed on Control-t ??  XEmacs is the only one I seem to remember that does it on Windows.  But I don't want to suffer through the rest of the learning curve.

Failing that maybe one where you can add a hotkey and custom command easily?
That's the most common typo for me and I can't believe it's not a standard feature like deleting a line.

edit: I know the editor in Visual Studio 2008 does it, but I don't want to wait 3 minutes for it to open.  Looking for something like EditPad Lite or NotePad++ but with Control-t transpose function.
« Last Edit: July 23, 2010, 01:19:10 PM by MilesAhead » Logged

"Genius is not knowing you can't do it that way."
- MilesAhead
AndyM
Charter Member
***
Posts: 616


see users location on a map View Profile Give some DonationCredits to this forum member
« Reply #1 on: July 23, 2010, 02:09:54 PM »

Or you could write a short Autohotkey script that would fix your typo with a Control-t no matter where you were typing (eg the Quick Reply in a DonationCoder forum  Wink  )
Logged
MilesAhead
Member
**
Posts: 4,947



View Profile WWW Give some DonationCredits to this forum member
« Reply #2 on: July 23, 2010, 03:13:50 PM »

Yeah, but then I'd have to decide if I should pass it through or eat the key.  Control T is a pretty common hotkey that's likely to do something else in an editor. I don't know why more editors don't have transpose.  Doesn't anyone touch type?

edit: plus I think the method would end up being pretty sloppy.  Send keys, copy to clipboard, etc.. which is likely to interfere with the clipboard likely to be in use by the editor. It would be smoother all around if the function was built in.

« Last Edit: July 23, 2010, 04:19:28 PM by MilesAhead » Logged

"Genius is not knowing you can't do it that way."
- MilesAhead
AndyM
Charter Member
***
Posts: 616


see users location on a map View Profile Give some DonationCredits to this forum member
« Reply #3 on: July 23, 2010, 08:10:38 PM »

If transposing the last two letters of a word only happens in your text editor, then by all means write a Control-T macro for that editor.  I use Boxer and Word and it would be easy to write a macro for either.

But if it happens elsewhere, I'd still think about a system-wide macro.  If Control-t is too general, pick something more obscure (Shift-Ctrl-1, Ctrl-Alt-q).

If the cursor is already at the end of the word, seems like the code would be a simple SelectOneCharacterToLeft,Cut,CursorLeft,Paste - only four keys to send:  ShiftCursorLeft/Ctrl-x/CursorLeft/Ctrl-v .  This should work regardless of which clipboard is used (system or editor) if the editor uses Ctrl-x and Ctrl-v to cut and paste using it's internal clipboard (Boxer does this).
 
I take your point about bumping whatever was originally in the clipboard.  I use a clipboard manager with quick hotkeys to jump to an earlier clip.
Logged
AndyM
Charter Member
***
Posts: 616


see users location on a map View Profile Give some DonationCredits to this forum member
« Reply #4 on: July 23, 2010, 08:13:56 PM »

Or if  you already have a text editor you like, write an autohotkey script that is only active when that editor has focus.  You'd still overwrite the current clipboard contents but you wouldn't have to worry about a Ctrl-t conflict.
Logged
skwire
Global Moderator
*****
Posts: 4,114



Another Coding Snack request? Om nom nom...

see users location on a map View Profile WWW Give some DonationCredits to this forum member
« Reply #5 on: July 24, 2010, 01:40:38 AM »

There is no need to use the clipboard.  Consider the following AHK code:

Formatted for Autohotkey with the GeSHI Syntax Highlighter [copy or print]
  1. {
  2.    Key_3 := Key_2, Key_2 := Key_1
  3.    Input, Key_1, V I L1
  4. }
  5.  
  6.  
  7. ^t::
  8. {
  9.    SendInput, {Backspace 2}
  10.    SendInput, % Key_2 . Key_3
  11. }

The above snippet should work anywhere to swap the last two typed characters without using the clipboard.  Alternately, you could easily restrict it down to only certain applications.  Obviously, minimal testing has been done with this but it seems to work pretty well.
« Last Edit: July 24, 2010, 01:43:11 AM by skwire » Logged

AndyM
Charter Member
***
Posts: 616


see users location on a map View Profile Give some DonationCredits to this forum member
« Reply #6 on: July 24, 2010, 11:16:29 AM »

There is no need to use the clipboard.

That's much better!
Logged
MilesAhead
Member
**
Posts: 4,947



View Profile WWW Give some DonationCredits to this forum member
« Reply #7 on: July 25, 2010, 05:09:03 PM »

Thanks for the macro and ahk code. smiley

edit: thanks skwire.  Tried it in EditPadLite and it worked.  smiley
« Last Edit: July 25, 2010, 05:40:19 PM by MilesAhead » Logged

"Genius is not knowing you can't do it that way."
- MilesAhead
MilesAhead
Member
**
Posts: 4,947



View Profile WWW Give some DonationCredits to this forum member
« Reply #8 on: July 25, 2010, 06:24:51 PM »

I just added a few lines to restrict the windows to a group of editors using the class names.

edit: added Chrome and Firefox browsers to the window group

[copy or print]
GroupAdd,EditorGroup, ahk_class TFormEditPadLite  ;EditPadLite
GroupAdd,EditorGroup, ahk_class wxWindowClassNR   ;FBIde
GroupAdd,EditorGroup, ahk_class SciTEWindow       ;Scite
GroupAdd,EditorGroup, ahk_class MAINFBEDIT        ;FBEdit
GroupAdd,EditorGroup, ahk_class Notepad           ;Notepad
GroupAdd,EditorGroup, ahk_class TFormMain         ;TreePad
GroupAdd,EditorGroup, ahk_class Chrome_WidgetWin_0   ;Chrome Browser
GroupAdd,EditorGroup, ahk_class MozillaUIWindowClass ;Firefox Browser

Loop
{
    Key_3 := Key_2, Key_2 := Key_1
    Input, Key_1, V I L1
}
Return

#IfWinActive, ahk_group EditorGroup
^t::
{
    SendInput, {Backspace 2}
    SendInput, % Key_2 . Key_3
}
Return
« Last Edit: July 26, 2010, 09:27:18 PM by MilesAhead » Logged

"Genius is not knowing you can't do it that way."
- MilesAhead
skwire
Global Moderator
*****
Posts: 4,114



Another Coding Snack request? Om nom nom...

see users location on a map View Profile WWW Give some DonationCredits to this forum member
« Reply #9 on: July 25, 2010, 06:35:55 PM »

Thanks for the macro and ahk code. smiley

edit: thanks skwire.  Tried it in EditPadLite and it worked.  smiley

You're welcome.  Happy to help.
Logged

MilesAhead
Member
**
Posts: 4,947



View Profile WWW Give some DonationCredits to this forum member
« Reply #10 on: August 12, 2010, 08:14:24 PM »

Looking around on ahk forum I saw that I was overly concerned about the clipboard when doing a hotkey for transposing characters. Using the clipboard has the advantage that I can move the caret, then later come back and fix a transpose typo.  This implementation is just a minimal macro.  It will not work correctly unless there are at least 2 characters to the left of the caret when you hit the hotkey. If the caret is at the start of a line or to the right of the first character, the macro will just end up eating a character. Also the app taking the input must be in Insert Mode.  Still, I get quite a bit of use out of it.  Anytime I want to add an app I just check that the app doesn't use ^t itself, then add its class name to the list for the window group.

[copy or print]
#SingleInstance force
#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%
GroupAdd,EditorGroup, ahk_class TFormEditPadLite  ;EditPadLite
GroupAdd,EditorGroup, ahk_class wxWindowClassNR   ;FBIde
GroupAdd,EditorGroup, ahk_class SciTEWindow       ;Scite
GroupAdd,EditorGroup, ahk_class MAINFBEDIT        ;FBEdit
GroupAdd,EditorGroup, ahk_class Notepad           ;Notepad
GroupAdd,EditorGroup, ahk_class TFormMain         ;TreePad
GroupAdd,EditorGroup, ahk_class Chrome_WidgetWin_0   ;Chrome Browser
GroupAdd,EditorGroup, ahk_class MozillaUIWindowClass ;Firefox Browser

#IfWinActive, ahk_Group EditorGroup
^t::
  ClipSaved := ClipboardAll ; save entire clipboard
  Clipboard= ; clear clipboard
  Send {Shift Down}{Left}{Shift Up} ; select char left of caret
  Send ^c ; copy char
  ClipWait,0 ;give copy time to complete
  ; the caret is positioned to insert
  ; the char from the clipboard. Editor
  ; must be in Insert Mode for it to work.
  ; The char is inserted, and caret positon restored.
  ;
  Send {Right}
  Send {BackSpace}
  Send {Left}
  Send {Raw}%Clipboard% ; avoid puntuaction being interpreted
  Send {Right}
  Clipboard := ClipSaved
  ClipSaved = ; free memory
Return
Logged

"Genius is not knowing you can't do it that way."
- MilesAhead
Pages: [1]   Go Up
  Reply  |  New Topic  |  Print  
 
Jump to:  
   Forum Home   Thread Marks Chat! Downloads Search Login Register  

DonationCoder.com | About Us
DonationCoder.com Forum | Powered by SMF
[ Page time: 0.043s | Server load: 0.13 ]