Skip to content

Instantly share code, notes, and snippets.

@patrickclery
Last active February 1, 2023 11:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save patrickclery/e938b81408be0b95b1a56ee42117d793 to your computer and use it in GitHub Desktop.
Save patrickclery/e938b81408be0b95b1a56ee42117d793 to your computer and use it in GitHub Desktop.
How To Create A Rubocop Keymap In Rubymine

How To Create A Rubocop Keymap In Rubymine

  1. Go to Settings > Tools > External Tools

Screenshot_20211014_145200

  1. Click "+" to add a new tool. Copy the details below, (replace /home/patrick/bin with /home/<YOUR_USER>/bin)

Screenshot_20211014_145017

  1. Create an empty Rubocop script using this command:
mkdir -p $HOME/bin && touch $HOME/bin/rubocop.sh && chmod +x $HOME/bin/rubocop.sh
  1. Open rubocop.sh in your favorite editor (RubyMine, obviously) and save this:
#!/bin/sh

eval "RBENV_VERSION=2.7.4 bundle exec rubocop $@"

NOTE: If you're not using rbenv, remove it. Or change it to match your Ruby version.

  1. Add a Keymap in RubyMine. I use ^+⌘+L in MacOS or ^+Alt+L in Linux.

Screenshot_20211014_142651

  1. Test it by opening a file and pressing the Keymap sequence.

  2. (Optional) Repeat the process by adding another External Tool, bind it to a different Keymap, but enable showing the console. This is useful if you ever want to see Rubocop's output.

Screenshot_20211014_144821

@ddnexus
Copy link

ddnexus commented Oct 15, 2021

Nice, but do you really need all that?

This has always worked on my setup:

rubocop-autocorrect

@alexandrule
Copy link

@igorlvicente
Copy link

Nice, but do you really need all that?

This has always worked on my setup:

rubocop-autocorrect

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment