管理 IDE 和操作系统之间的键盘快捷键冲突 (Ubuntu)
我正在使用 IntelliJ IDEA,但我认为这适用于任何 IDE。
在 IDEA 中,一些非常有用的键盘快捷键与Ubuntu 键盘快捷键。一些示例:
- Ctrl+Alt+L :格式化源代码(映射到 Ubuntu 中的“锁定屏幕”) )
- Ctrl+Alt+Left :向后导航(映射到“切换到当前工作区左侧的工作区”) Ubuntu 中的“工作区”)
- ...
我已经使用 Ubuntu 很长时间了,我已经习惯了这些快捷方式。我一直使用它们在工作区之间切换、锁定会话...同时,我知道 IntelliJ 快捷键有多么有用,并且我想尽可能避免使用鼠标。
目前,我的“格式化源代码”的解决方法是 Alt+D (打开“代码”菜单),然后是“R”(“重新格式化代码”)。它工作正常,因为我不经常格式化代码,但它可以更好。不过,Ctrl+Alt+Left 没有真正的替代方案。
您如何在 IDE 中管理这些冲突?
您是否只是将所有冲突的 IDE 键盘快捷键重新映射到其他东西(然后当您与使用不同快捷键的同事结对编程时迷失方向......)?
您是否重新映射 Linux 键盘快捷键(即使您“习惯”它们)?
有没有办法让键盘快捷键“上下文化”?我的意思是:在编码时按一个键进入“IDEA 模式”(所有冲突的 Ubuntu 快捷方式都暂时停用),再次按该键返回“标准模式”(Ubuntu 快捷方式已反应)。
对于如何解决这个问题,您还有其他想法/技巧吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(10)
我也使用 Ubuntu,并且禁用了本机 (Ubuntu) 命令 Ctrl + Alt + L 因为我更喜欢 IntelliJ 的格式代码而不是本机 Ubuntu命令。然而,在第二种情况下,我更喜欢 Ubuntu 的快捷方式,所以我没有改变任何东西。
所以基本上,您可以选择您更需要哪个选项,然后采取相应的行动。
当然,直到 IDEA 变得对 Ubuntu 友好为止。
最后,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.
我将 ubuntu 快捷方式更改为
与原来类似。对我来说效果很好。
I changed ubuntu shortcuts to
similar to original. Works fine for me.
在 Ubuntu 中,禁用 ctrl+alt+left 键绑定的方法是打开系统设置 ->键盘->快捷方式(选项卡)->导航 。滚动到“切换到左侧工作区”,单击它并按 Backspace。愚蠢的是,甚至在默认情况下只有一个桌面的 Ubuntu 14.04 中也启用了此功能。
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.
有一个功能请求提供 Ubuntu 友好的键盘映射。
重新映射什么,IDEA 还是 Linux 键?根据您更经常使用的内容自行决定。我猜你重新格式化代码的频率比锁定屏幕的频率高?因此,重新映射 Linux 并保留 IDEA 默认键盘快捷键。
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.
您只需将
super
(又名 Windows 键)与intellijidea
快捷方式结合使用,即可保留 Ubuntu 的默认快捷方式。,您只需
Ctrl + Alt + WinKey + L
格式化代码并按
Ctrl + Alt + WinKey + Left
用于向后导航
希望这有帮助
You can just use the
super
(aka Windows Key) in combination with yourintellijidea
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
这在 Ubuntu Studio 14.04 (XFCE) 中适用于我:
xfwm4-settings
This works for me in Ubuntu Studio 14.04 (XFCE):
xfwm4-settings
为了禁用 XUbuntu 的 (xfce) 键盘映射
Alt + F8 和
Ctrl + Alt + 左/右箭头
我使用了
设置 ->窗口管理器->选项卡“键盘”
。在这里我能够清除这些映射。
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.
从 CrazyCoder 提供的功能请求链接:
“Gnome 的默认”对我来说很有效(我使用的是 ArchLinux、Gnome3、AndroidStudio/InteliJ),它重新映射了导航/返回到 Shift+Alt+Left(是“XWin 的默认”中的 Ctrl+Alt+Left,它没用)。
但现在它也可以切换键盘布局(Shift+Alt),另一个问题))可能我会将键盘切换器重新映射到其他东西,它比在 IDE/OS 中重新分配所有冲突的键还要简单。
From the link to feature request provided by CrazyCoder:
"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.
在“设置”部分的“键盘映射”中,您可以从 XWin、Gnome、Visual Studio、Eclipse 等中选择键盘映射模板...这可以通过选择 Gnome 解决 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.
为了让 intellij 热键正常工作,我在设置中禁用了下一个配置:
键盘快捷键(第 1 部分)
键盘快捷键(第 1 部分)
它帮助我与 F1-F12 按钮进行有效组合。但我仍然需要更改一些热键。
Ctrl + Alt + 左/右 -> Shift + Alt + 左/右
Ctrl + Alt + F7 -> Alt + F7
链接到我的 ubuntu 热键。
https://github.com/AnatoliiKurchak/intellij-ubuntu-hotkeys
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