Content

ramblings of a coldfusion developer

Developer Toolbox: AutoHotKey – Super Snippets

Wednesday 4 March 2009 - Filed under Code

So I’ve been working with a bunch of REALLY old code lately and one thing I run into over and over again is queries with no queryparam.

While I do have a snippet setup in CFEclipse to insert a queryparam:


But I still have to cut-n-paste the variable, etc. Kind of a pain when doing it over and over again. So I started tinkering with AutoHotKey (my favorite lazy tool) and came up with this:

;-- Wrap selected text in QueryParam (will first strip ' or ") ---
!q::
clipboard =
send ^c
clipwait, 1
If ErrorLevel = 0
StringReplace, clipboard, clipboard, ', , All
{
clipboard =
send ^v
}
return

So now I simply highlight my variable – hit my key combo (in this case [ALT]+[Q] and my text is copied to the clipboard – stripped of quote marks, wrapped in the queryparam and sent back to the editor!

Tagged: » »

2009-03-04  »  Jim Priest

Talkback x 8

  1. James Morrow
    4 March 2009 @ 5:02 pm

    Nifty tip, Jim.

    This reminds me that I need to setup more things like this in Eclipse.

    Thanks.

  2. Brandon Moser
    6 March 2009 @ 8:21 pm

    Jim,

    I’ve created a stack of CFQueryparam snippets in CFEclipse that wrap variables in old code queries. I’m not sure how I can share them, but I basically have the first part ” in the following box. Saves me tons of time. I love TextExpander on my Mac, but I’ve been looking for a something like this on Linux. Thanks.

  3. Brandon Moser
    6 March 2009 @ 8:25 pm

    And of course my code snippet doesn’t show up. I think this should work…
    Start text: <cfqueryparam value="
    End text: " cfsqltype="cf_sql_char" />

    Also, I sync them between machines with Dropbox. Super helpful that they are stored in xml files.

  4. Jim
    6 March 2009 @ 8:26 pm

    I was just Twittering about this :)

    Snippets are nice – you can zip them up and easily share them. The nice thing about a text expander is you can use it anywhere. If I have code open in Notepad I can still dump in my ‘snippets’. So far I haven’t found anything similar on Linux :(

  5. Jim
    7 March 2009 @ 12:06 am

    Excellent idea about sharing them with Dropbox!!

  6. Cliff Pearson
    7 April 2009 @ 3:52 am

    Nice tips – thanks guys.

    Just in case anyone has been living under a rock (B->), don’t forget to investigate Snipex (http://www.markdrew.co.uk/blog.....s-released) – a snippet server solution built into CFE by the delectable Mark Drew.

  7. James Moberg
    18 August 2009 @ 8:20 pm

    I’ve written a couple of AutoHotKey scripts that I use to clean up the clipboard, optimize CSS and repurpose content for lists.
    http://www.ssmedia.com/utilities/autohotkey/

  8. Slipstream
    4 September 2009 @ 8:36 am

    I use C++ for the string processing. AutoHotKey puts the text on the clipboard, runs the helper exe, and pastes the result back into the original.

Share your thoughts

Re: Developer Toolbox: AutoHotKey – Super Snippets







Tags you can use (optional):
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>