Managing keyboard shortcut conflicts between IDE and OS (Ubuntu)
Solution 1
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
I changed ubuntu shortcuts to
- ctrl+win+L
- ctrl+win+Left
similar to original. Works fine for me.
Solution 3
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
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
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
Etienne Neveu
Hi. I'm french. I love web development, fresh orange juice, good movies, awesome books, chill electronic music, Brazilian Jiu-Jitsu, snowboarding, and traveling. I hate the war over general-purpose computing, the NSA's overreach, and patent trolls. But I also love Android, Scala, Spring Boot, Guava, Clean Code™, and Effective Java™. Authors I really respect: Robert C. Martin (Uncle Bob) on clean code Joshua Bloch on java best practices and API design Martin Fowler on refactoring and architecture Brian Goetz on java concurrency Michal Zalewski on web app security
Updated on January 08, 2021Comments
-
Etienne Neveu over 3 years
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?
-
Etienne Neveu about 13 yearsCrazyCoder / askmo : I upvoted both of you. Your answers are pragmatic. I was secretly hoping there was a trick to manage keymaps without remapping everything, but I guess I'll just have to accept it. I'm still going to wait a few days before accepting your answers, in case somebody knows a trick to avoid doing that.
-
sandalone about 13 yearsUnfortunatelly, there is not a better solution than the one I told you. Until IDEA makes changes, you cannot do much but change what you can - and at the moment you can only change Ubuntu's shortcuts. PS. I'd suggest you dig the net to find Ubuntu utility that can enable/disable all shortcuts. If you find such tool, please post it here, because I was unable to find it myself. Thanks!
-
Etienne Neveu about 13 yearsI might have found something, going to try it tonight: askubuntu.com/questions/17315/… . I can create a bash script that enables / disables a list of shortcuts using the gconftool-2 command, and trigger it using a specific keyboard shortcut :)
-
Jas over 10 yearshow did you change it?
-
Lambart almost 10 yearsI changed the Ubuntu "Lock Screen" shortcut to simply be Win-L. @Jas, if you are having trouble remapping shortcuts with the "Win" (aka "Super") key, perhaps my answer to another keymapping question will help: askubuntu.com/a/349614/54675
-
postfuturist almost 10 yearsFor some reason, these settings reset themselves recently (maybe after some package updates) on my desktop. I don't know why.
-
noun lace about 8 yearsDown voted because because ubuntu short keys still conflicts with gnome. Refer to jetbrains.com/idea/help/reformatting-source-code.html
-
fIwJlxSzApHEZIl over 6 yearsYou don't have to remap anymore.
Settings -> Keyboard -> Shortcuts
will let you modify most inherent keyboard shortcuts in Ubuntu 16.04. Additionally, compizconfig-settings-manager will allow you to modify any other hotkeys not covered in the Ubuntu native settings to your liking. -
Admin about 5 yearsI ended up here for a somewhat different but related problem and using super+(my shortcut) worked for me. Is this a standard way of escaping system shortcuts or just a relatively common way?