How to combine "Reformat Code" and "Optimize Imports" into a Single Hotkey in Rider

I would like to combine two actions into a single hotkey in mac: 

  1.  Reformat Code (currently bound to Option+Cmd+L)
  2. Optimize Imports (currently bound to Ctrl+Option+O)

 

 

0
1 comment

Hi Zhoujiazhiwork

This is definitely possible. There is a Reformat and Cleanup Code action. You could use it “as is” with a shortcut or create a separate profile which includes only Reformat code and Optimize Imports. The easiest way to do this is to create a copy of Built-in: Reformat code profile and add Optimize imports there. 

Also, one can set this profile as default for silent cleanup and launch it with a shortcut without any additional questions. There are no default shortcuts for both these actions if you use the default IntelliJ keymap, but they could be added in File | Settings | Keymap

0

Please sign in to leave a comment.