I must admit, I get the creeps when I look at some code and see unterscores used all over the place. It's so old school to me. And it has been my (lame) excuse for a while for not digging deeper into the Ruby language.
But there is one place where underscores make sense: Naming your unit test methods! It is just good to write somthing like
Unfortunately it is a PITA to type such as thing. Today I came accros a really good idea from Jean-Paul Boodhoo while watching a dnrTV screencast. He has build himself a Visual studio macro that just picks up the current selection and replaces every space with an underscore.
As I was sitting on the train while watching, there was no way of downloading this macro (and I'm not sure if it can be downloaded), so I had to role my own and here it is:
DTE.Find.FindWhat = " "
DTE.Find.ReplaceWith = "_"
DTE.Find.MatchCase = False
DTE.Find.MatchWholeWord = False
DTE.Find.MatchInHiddenText = False
DTE.Find.PatternSyntax = vsFindPatternSyntax.vsFindPatternSyntaxLiteral
DTE.Find.ResultsLocation = vsFindResultsLocation.vsFindResultsNone
DTE.Find.Action = vsFindAction.vsFindActionReplaceAll
It seems to work nicely and I have assigned it to the Ctrl-Shift-Insert Keyboard shortcut.