管理 IDE 和操作系统之间的快捷键冲突(Ubuntu)

我使用的是 IntelliJ IDEA,但我认为这适用于任何 IDE。

在 IDEA 中,一些 非常有用的键盘快捷键与 Ubuntu 键盘快捷键冲突:

  • Ctrl + Alt + L : 格式化源代码(在 Ubuntu 中映射到“ Lock Screen”)
  • Ctrl + Alt + Left : 向后导航(在 Ubuntu 中映射为“切换到当前工作区左侧的工作区”)
  • ...

我已经使用 Ubuntu 很长时间了,我已经习惯了这些快捷方式。我一直使用它们在工作区之间切换,锁定我的会话... ... 同时,我知道 IntelliJ 快捷方式有多么有用,我想尽可能避免使用鼠标。

目前,“格式化源代码”的解决方案是 Alt + D(打开“代码”菜单) ,然后是“ R”(“重新格式化代码”)。它工作得很好,因为我不经常格式化代码,但它可以更好。然而,ABC2 + ABC0 + Left没有真正的替代品。

如何在 IDE 中管理这些冲突?

您是否只是简单地将所有冲突的 IDE 键盘快捷方式重新映射到其他地方(然后在与具有不同快捷方式的同事进行编程时迷失方向... ...) ?

您是否重新映射 Linux 键盘快捷键(即使您已经“习惯”它们) ?

有没有办法使键盘快捷键“上下文相关”?我的意思是: 在编写代码时按一个键进入“ IDEA 模式”(所有冲突的 Ubuntu 快捷方式暂时停用) ,再按一次键返回“标准模式”(Ubuntu 快捷方式被激活)。

对于如何处理这个问题,你还有其他的想法/提示吗?

33270 次浏览

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.

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.

I changed ubuntu shortcuts to

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

similar to original. Works fine for me.

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.

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.

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.

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

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.

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

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