Keyboard shortcut: [:shift_space] => 'underscore' Follow
It would be really cool if i could hit [Shift]-[Space] and type an underscore. I've mentioned this before on an unrelated post, but it would save me about .02 seconds everytime i go to type one with Ruby. And I happen to use alot of verbose descriptive var names. Is there some way to define keyboard shortcuts that type something instead of taking an action?
Please sign in to leave a comment.
Hello David,
Sorry, I didn't understand it. Could you please clarify what exactly you are typing, what is expected behavior and what you get within RubyMine?
Regards,
Oleg
Its really something that's not in any IDE's or text editors. Whenever you type shift space, it does nothing. In ruby you type alot of variables in snake case(snake_case_vars). But when you type underscore, you kind of have to reach to get to the key. So it would be really cool to just hit shift-space and have that type an underscore.
Hi,
You can easily add such action using RubyMine ruby extensions api:
1. create a file (e.g. undescore_action.rb) with content
2. Create empty dir (e.g. rubymine_ext) and place the file there
3. Now you need to active the extension in RubyMine: Open File|Settings|Extensions dialog, press "Add" button and choose your rubymine_ext folder
4. Apply settings and relaunch RubyMine
5. Now "Insert Undescore" action should be avaiable
6. "Shift space" action is already reserved for basic autocompletion action, so let's fix it.
Open File | Settings | Keymap dialog
7. BuilIn keymaps are readonly, so press "Copy" button to create a customized version
8. Now type "unders" in search field to quickly navigate to our insert undescore action
9. Press "Add Keyboard Shortcut..." button and press SHIFT+SPACE
10. Press "Ok" and confirm removing shortcut from other actions
11. Now shortcut tip is shown near acton name
and you can start using it =)
P.S: Also see javascript:;
Hi David,

It's a nice hack with Shift-Space instead of the underscore.
I also wanted to mention that RubyMine's code completion allows you to skip the underscores while typing. Check out the attached screenshot.
Hope it helps,
-Eugene
Awesome, thanks for the tip. I had no idea you could wire up extensions like that!
The recognition of terms without an underscore for code completion makes it that much more robust. Thanks again, Eugene!