Keyboard shortcut: [:shift_space] => 'underscore'

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?


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?



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.



You can easily add such action using RubyMine ruby extensions api:

1. create a file (e.g. undescore_action.rb) with content

include Java require 'default_scripts_groups' require 'editor_action_helper' register_editor_action "InsertUnderScore",                        :text => "Insert underscore",                        :description => "Inserts '_' char",                        :shortcut => "shift space",                        :group => "ScriptsRuby" do |editor, file|   editor.insert_text "_" end

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
Screen Shot 2011-08-07 at 9.29.40 PM.png
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
Screen Shot 2011-08-07 at 9.35.22 PM.png
9. Press "Add Keyboard Shortcut..." button and press SHIFT+SPACE
Screen Shot 2011-08-07 at 9.38.13 PM.png
10. Press "Ok" and confirm removing shortcut from other actions
Screen Shot 2011-08-07 at 9.39.38 PM.png
11. Now shortcut tip is shown near acton name
Screen Shot 2011-08-07 at 9.40.13 PM.png

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,


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!     


Please sign in to leave a comment.