About the author

Steven HarmanSteven Harman is a passionate developer who believes that writing great software isn't just a job, its a craft.

ASP.NET MVP

For recent posts and more about me, scroll to the bottom.

Subscribe

  • Subscribe to my feed. via RSS
  • Subscribe via email via email

News

devLINK Technical Conference

Jobs

Badges

  • Subtext Project
  • Support Subtext
  • HiddenNetwork.com Banner

Save Your Fingers, Use a BDD AutoHotKey Script!

Tired of typing all those underscores_while_writing_your_BDD_specifications? Yeah, I wasn’t really either. However I’ve heard read complaints from some folks that typing the underscore so many times was getting annoying, so they had opted for PascalCasing instead.

Just deal with it

Maybe its because of my exposure to Ruby and the joy that is RSpec, but I don’t think such minor annoyance is enough of a reason to top using a more readable style. Repetitive Stress Injury, be damned!

Or maybe not! The other day while cleaning out my RSS reader I came across AutoHotKey (thanks JP), a utility that allows you to launch custom scripts, macros, etc… via keyboard shortcuts.

No more Ctrl + -

AutoHotKey in actionThanks to some great work by JP, Aaron Jensen, and David Tchepak we have an AutoHotKey script that can automagically replace any space characters with an underscore, as you type, in real time.

You can toggle the script on and off using the Ctrl + Shift + U hot key, a.k.a – keyboard shortcut. The script is also smart enough to turn itself off when you hit either Enter or Escape keys. And Aaron even has a version of the script that is only active when Visual Studio is active. However, being that I use e-Text Editor as my Ruby IDE, I like having the script available everywhere in the OS.

AutoHotKey custom iconDave added a little more sugar by tweaking the script so it shows a custom icon in the Windows task tray when the script is running, or not. A nice touch to really round out the experience.

Get yourself some AHK!

The one thing I found a little confusing was how exactly to get the script up and running, with the icons. Luckily, you won’t have to struggle… I’ll lay it out for ya’. :)

  1. Get AutoHotKeydownload and install it.
  2. Grab JP’s script – or Aaron’s modified one if want. Save the script as some-name-here.ahk, wherever you want, I have mine in my Documents directory.
  3. Pull down Dave’s icons – copy the two icon files to the same directory as your .ahk script from step 2.
  4. Launch your script!

Enjoy!

kick it on DotNetKicks.com

What others are saying.

# Save Your Fingers, Use a BDD AutoHotKey Script!
Gravatar DotNetKicks.com
Jun 08, 2008
You've been kicked (a good thing) - Trackback from DotNetKicks.com
# re: Save Your Fingers, Use a BDD AutoHotKey Script!
Gravatar Scott
Jun 08, 2008
I think you have a bug in your post. You are replacing spaces with underscores, not the other way around.

Auto Hotkey is amazing. Thanks for linking this script.
# re: Save Your Fingers, Use a BDD AutoHotKey Script!
Gravatar Steven Harman
Jun 08, 2008
@Scott, doh!

You are right, I must have had a brain-fart when I typed that out. The point of the script is in fact to replace spaces with underscores thus allowing you to type as quickly and accurately as you normally would, without the need to hit Ctrl + -.

Thanks for pointing out the typo, I've corrected it in the post.
# re: Save Your Fingers, Use a BDD AutoHotKey Script!
Gravatar Joe Ocampo
Jun 08, 2008
Wow!!! Nice find. I am going to see if I can write a bash script that can do this in the Mac as well. Saweeeet!
# re: Save Your Fingers, Use a BDD AutoHotKey Script!
Gravatar Jay R. Wren
Jun 08, 2008
Sweet lord!!! Did you see my tweets the day prior when I was making_fun_of_you_guys?

I should make fun of you more often!
# re: Save Your Fingers, Use a BDD AutoHotKey Script!
Gravatar Steven Harman
Jun 11, 2008
@Joe, Joe O'Brien says he uses Quicksilver to get similar functionality in OSX... might want to dig into that and see what you find. Or just shoot Joe a Tweet.
# Tweak of
Tweak of

What do you have to say?

Title*
Name*
Email (never displayed)
(will show your gravatar)
Url
Comment*  
Please add 1 and 7 and type the answer here: