为了实现Windows、Linux、macOS三个平台一致的键盘快捷键体验,核心策略是统一使用Windows与Linux风格的快捷键,调整macOS下的Control键和Command键的映射关系,并微调macOS部分快捷键配置。

Control键映射为Command键,坏处很明显,需要放弃所有的原生Control组合功能,包括Control+C停止命令等常用终端命令。对于iTerm等终端工具,可以单独设置快捷键以实现Control+C的效果,但对于Jetbrains和VSCode等终端界面,无法很好的支持需要Control组合的快捷键。

Control键映射为Command键的同时,也将Command键也映射为Control键(双向映射),可以通过Command+C实现原来Control+C的功能,但又会打乱macOS原本的一些快捷键习惯,如:Command+Tab切换窗口、Command+Space打开聚焦搜索、Command+Q关闭应用等都需要切换为Control组合快捷键。

没有一套完美的跨平台快捷键统一方案,下文提供一种将Control键映射为Command键的配套修改思路,以供参考。

一、macOS全局快捷键

点击【设置】-【键盘】-【键盘快捷键】,进入系统快捷键设置界面。

将【修饰符】中的【Control键】修改为【Commond键】,以适配Windows/Linux的使用习惯。

动作原快捷键新快捷键备注
服务/搜索/聚焦Shift+Command+F-避免与Jetbrains快捷键冲突
聚焦/显示APP-Option+A-

二、Jetbrains快捷键

点击【Settings】-【Keymap】,进入IDEA/PyCharm快捷键设置界面。

切换预定义的键位映射为:【Intellij IDEA Classic】。

动作原快捷键新快捷键备注
Move Caret to Previous WordOption+←Command+←-
Move Caret to Next WordOption+→Command+→-
Move Caret to Previous Word with SelectionOption+Shift+←Command+Shift+←-
Move Caret to Next Word with SelectionOption+Shift+→Command+Shift+→-
Next MethodControl+↓Option+↓-
Previous MethodControl+↑Option+↑-
Select Next TabControl+→Option+→
Select Previous TabControl+←Option+←
Find in FilesControl+Shift+FCommand+Shift+F-
Replace in FilesControl+Shift+RCommand+Shift+R-

其它不一致的快捷键:

  • top:Show Project window、Settings、Generate、Run Anything、Attach to Process
  • Build projects:New in This Directory
  • Basic editing:Join Lines、Scratch File
  • Multiple carets and selection ranges:…
  • Coding assistance:Basic Completion、Type-Matching Completion、Second Basic Completion、Complete Code with AI Assistant、Generate Code with AI Assistant、Quick Documentation、Generate
  • Context navigation:Switcher、Toggle Anonymous Bookmark、Toggle Bookmark with Digit、Go to Bookmark with Digit、Show Mnemonic Bookmarks、Show Bookmarks window、Show Structure window、Show Find window Code analysis:Show Problems window
  • Run and debug:Run Anything、Attach to Process、Show Run window、Show Debug window、Show Services window
  • Refactorings:Safe Delete
  • Global VCS actions:VCS Operations Popup、Next Change、Previous Change、Show Version Control window、Show Commit window
  • Diff Viewer:Accept Left Side、Accept Right Side、Select Opposite Diff Pane
  • Tool windows:含有Option的Show xxx window

三、iTerm快捷键

点击【Settings】-【Keys】-【Key Bindings】,进入iTerm快捷键设置界面。

动作原快捷键新快捷键备注
Send Hex Codes: 0x03-Command+C中断命令
Copy Selection or Send-Command+Shift+C复制
Paste or Send-Command+Shift+V粘贴