Managing keyboard shortcut conflicts between IDE and OS (Ubuntu)

UbuntuIntellij IdeaIdeKeyboard Shortcuts

Ubuntu Problem Overview


I'm using IntelliJ IDEA, but I think this applies to any IDE.

In IDEA, some very useful keyboard shortcuts conflict with Ubuntu keyboard shortcuts. Some examples:

  • Ctrl+Alt+L : formats the source code (mapped to "Lock Screen" in Ubuntu)
  • Ctrl+Alt+Left : navigates backward (mapped to "switch to workspace on the left of the current workspace" in Ubuntu)
  • ...

I've been using Ubuntu for a long time, and I'm used to these shortcuts. I use them all the time to switch between workspaces, lock my session... At the same time, I know how useful the IntelliJ shortcuts can be, and I want to avoid using the mouse as much as possible.

Currently, my workaround for "format source code" is Alt+D (opens the "Code" menu), followed by "R" ("Reformat Code"). It works okay, since I don't format code that often, but it could be better. There is no real alternative for Ctrl+Alt+Left, though.

How do you manage these conflicts in your IDE?

Do you simply remap all the conflicting IDE keyboard shortcuts to something else (and then get lost when you are pair programming with a colleague with different shortcuts...)?

Do you remap the Linux keyboard shortcuts (even though you are "used" to them)?

Is there a way to make keyboard shortcuts "contextual"? By this, I mean: hit a key to go into "IDEA mode" when coding (all conflicting Ubuntu shortcuts are temporarily deactivated), hit the key again to go back to "Standard mode" (Ubuntu shortcuts are reactived).

Do you have any other ideas / tips on how to manage this problem?

Ubuntu Solutions


Solution 1 - Ubuntu

I use Ubuntu as well and I disabled the native (Ubuntu) command Ctrl + Alt + L because I prefer IntelliJ's format code than this native Ubuntu command. However, in the 2nd case I prefered Ubuntu's shortcut so I didn't change anything.

So basically, you can choose which option you need more and then act accordingly.

Of course, until IDEA becomes Ubuntu friendly.

In the end, Ubuntu will always prefer its shortcuts and so far I haven't found any tool that can disable native shortcuts on request.

Solution 2 - Ubuntu

I changed ubuntu shortcuts to

  • ctrl+win+L
  • ctrl+win+Left

similar to original. Works fine for me.

Solution 3 - Ubuntu

In Ubuntu, the way to disable the ctrl+alt+left keybinding is to open System Settings -> Keyboard -> Shorcuts(tab) -> Navigation . Scroll to "Switch to workspace left", click on it and hit Backspace. It is silly that this is even enabled for stock Ubuntu 14.04 where there is only one desktop by default.

Solution 4 - Ubuntu

There is a feature request to provide Ubuntu friendly keymap.

What to remap, IDEA or Linux keys? Decide yourself depending on what you are using more often. I guess you reformat code more often than lock screen? So remap Linux and leave IDEA default keyboard shortcut.

Solution 5 - Ubuntu

You can just use the super (aka Windows Key) in combination with your intellijidea shortcut, in order to leave the default shortcuts for Ubuntu.

So, you can just

Ctrl + Alt + WinKey + L to format the code and

Ctrl + Alt + WinKey + Left for navigating backward

Hope this helps

Solution 6 - Ubuntu

This works for me in Ubuntu Studio 14.04 (XFCE):

  • Open Windows Manager: xfwm4-settings
  • Go to Keyboard tab
  • Scroll down to conflicting Action
  • Hit Clear button or change action to different shortcut

Solution 7 - Ubuntu

In order to disable XUbuntu's (xfce) keymap for Alt + F8 and Ctrl + Alt + Left/Right Arrow I used Settings -> Window Manager -> tab "Keyboard".

Here I was able to clear these mappings.

Solution 8 - Ubuntu

From the link to feature request provided by CrazyCoder: > Actually, there are several bundled schemes: "Default for GNOME", "Default for KDE" created exactly for that purpose. >I have not checked now particular shortcuts like Ctrl+Alt+L, but these schemes were created to avoid conflicts with GNOME and KDE respectively.

"Default for Gnome" did the trick for me (I'm on ArchLinux, Gnome3, AndroidStudio/InteliJ), it remapped Navigate/Back to Shift+Alt+Left (was Ctrl+Alt+Left from "Default for XWin" and it didn't work).

But now it switches may keyboard layout as well (Shift+Alt), another problem )) Probably I'll remap keypad switcher to something else, it is still simpler then reassigning all the conflicting keys in IDE/OS.

Solution 9 - Ubuntu

In 'Settings' section 'Keymap' you can choose the keymaps template from XWin, Gnome, Visual Studio, Eclipse, etc... This solve any problem in Ubuntu by choosing Gnome.

Solution 10 - Ubuntu

In order to have working intellij hotkeys I've disabled next configuration in settings:

keyboard shortcuts (part 1)

keyboard shortcuts (part 1)

It helped me to have working combinations with F1-F12 buttons. But I still had to change some hotkeys.

Ctrl + Alt + Left/Right -> Shift + Alt + Left/Right

Ctrl + Alt + F7 -> Alt + F7

Link to my hotkeys for ubuntu.

https://github.com/AnatoliiKurchak/intellij-ubuntu-hotkeys

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionEtienne NeveuView Question on Stackoverflow
Solution 1 - UbuntusandaloneView Answer on Stackoverflow
Solution 2 - UbuntufantomView Answer on Stackoverflow
Solution 3 - UbuntupostfuturistView Answer on Stackoverflow
Solution 4 - UbuntuCrazyCoderView Answer on Stackoverflow
Solution 5 - UbuntubesilView Answer on Stackoverflow
Solution 6 - UbuntuluboskrnacView Answer on Stackoverflow
Solution 7 - UbuntuWheneverView Answer on Stackoverflow
Solution 8 - UbuntuMixazView Answer on Stackoverflow
Solution 9 - UbuntuRiRomainView Answer on Stackoverflow
Solution 10 - UbuntuA. KurchakView Answer on Stackoverflow