We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 12983
    • 108 Posts
    Here it is an AutoHotKey script that lets you transparently use your favourite editor instead of editing into the textareas. Benefits involve e.g. syntax highlighting. All started with the suggestion for a "coding snack" I’ve made here, it was easy to modify an existing script. Hope you like it smiley

    ;Edit.ahk 
    ;Edit contents of text boxes in favourite editor 
    ;2/21/05 - savage -- modified 30/08/06 insert_nick
    
    ; Usage: Configure the following two paths with your preferred text-editor and temp file (if doesn't exist then it's created). If you have a cursor active into a textarea (e.g. in a browser window) you can press CTRL-ALT-C to load its content into the text editor; make your changes, and press CTRL-ALT-V to transfer the modified content back into the original textarea. The text editor is still open with the temp file loaded, so you can edit it again and again, committing changes into the original textarea by pressing CTRL-ALT-V from the editor (because it saves the document to make sure it is updated with edits).
    ;
    ; Summing up:
    ; CTRL-ALT-C to transfer a textarea content into the text editor
    ; CTRL-ALT-V to transfer the active document of the text editor into the original source textarea
    ;
    ; Make sure you adapt the script to let it work with your favourite text editor, e.g. the one considered here saves with CTRL-S, but maybe your one uses a different keyboard shortcut.
    
    ;put the path to your editor here, you may need to add some parameters if your editor needs any 
    editor = F:\path\to\favourite\text\editor.exe 
    
    ;path to place the temp file - you'll probably want to change this. The extension doesn't matter, but it's useful if you know what type of files you're going to edit and your editor can syntax-highlight the code reading the extension
    path = F:\tmp\textarea_temp.php 
    
    
    ;ctrl-alt-c 
    ;Selects all text in the textarea, saves to temp file, runs editor on file
    ^!C:: 
       SetKeyDelay, 1 
       WinGetActiveTitle, wtitle 
       temp = %clipboard% 
       Send, ^a 
       Send, ^c 
       ;if the clipboard didn't change then the box was empty 
       If clipboard = %temp% 
           clipboard = 
       ;In case it wasn't properly deleted 
       FileDelete, %path% 
       FileAppend, %clipboard%, %path% 
       ;refill the clipboard so you can paste things in the editor 
       clipboard = %temp%
       Run, %editor% "%path%"   
    return   
    
    ;ctrl-alt-v 
    ;Paste content of the temp file into the textarea
    ^!V::   
       ;save the clipboard again in case you copied anything in the editor 
       temp = clipboard
       Send, ^s  ;(the text editor's save command)
       Sleep, 500
       FileRead, clipboard, %path% 
       WinActivate, %wtitle% 
       WinWaitActive, %wtitle% 
       Send, ^a 
       Send, ^v 
       clipboard = %temp% 
    return