I was once with an agile company that had pairing stations throughout the work area. Some pairing stations were Windows-based and some where Mac-based. The one particular thing that I did not appreciate was that the key bindings in IntelliJ IDEA or Android Studio were different whether you were working on a Mac or on a Windows.
If you are a type of software developer or a cross operating system user where keyboard consistency (the physical key distance, locations, feel, and keybindings) is very important, this documentation will be very helpful for you.
Whether you choose to use a mac keyboard or a windows keyboard as your primary keyboard, the goal of this technical documentation is to make your keyboard consistent and operating system independent.
This article will demonstrate the usage of a mac keyboard on windows for IntelliJ IDEA or Android Studio by adding mac key bindings using AutoHotKey.
Symbol | Description |
---|---|
# | Win Key (Windows Logo Key or Command Key in Apple Keyboards) |
! | Alt Key |
^ | Control Key |
+ | Shift Key |
& | An ampersand may be used between any two keys or mouse buttons to combine them into a custom hotkey. |
; Find Action (⌘+Shift+A) -> (Ctrl+Shift+A)
#+a::
{
Send ^+a
Return
}
; Duplicate Line (⌘+D) -> (Ctrl+D)
#d::
{
Send ^d
Return
}
; Delete Line (⌘+Backspace) -> (Ctrl+Y)
#backspace::
{
Send ^y
Return
}
; Quick Documentation (F1) -> (Ctrl+Q)
F1::
{
Send ^q
Return
}
; Find (⌘+F) -> (Ctrl+F)
#f::
{
Send ^f
Return
}
; Find in Path (⌘+Shift-F) -> (Ctrl+Shift+F)
#+f::
{
Send ^+f
Return
}
; Replace (⌘+R) -> (Ctrl+R)
#r::
{
Send ^r
Return
}
; Replace in Path (⌘+Shift+R) -> (Ctrl+Shift+R)
#+r::
{
Send ^+r
Return
}
; Move Statement Up (⌘+Shift+Up) -> (Ctrl+Shift+Up)
#+up::
{
Send !+{Up}
Return
}
; Move Statement Down (⌘+Shift+Down) -> (Ctrl+Shift+Down)
#+down::
{
Send !+{Down}
Return
}
; Extend Selection (⌘+Up) -> (Ctrl+W)
!up::
{
Send ^w
Return
}
; Shrink Selection (⌘+Down) -> (Ctrl-Shift+W)
!down::
{
Send ^+w
Return
}
; New (⌘+N) -> (Alt+Insert)
#n::
{
Send !{Insert}
Return
}
; Complete Current Statement (⌘+Shift+Enter) -> (Ctrl+Shift+Enter)
#+enter::
{
Send ^+{Enter}
Return
}
; Toggle Case (⌘+Shift+U) -> (Ctrl+Shift+U)
#+u::
{
Send ^+u
Return
}
; Jump to Navigation Bar (⌘+Up) -> (Alt+Home)
#up::
{
Send !{Home}
Return
}
; Navigate to Declaration (⌘+LeftClick) -> (Ctrl+LeftClick)
#LButton::
{
KeyWait, LButton, D
Send ^{LButton}
Return
}
; Navigate to Declaration (⌘+B) -> (Ctrl+B)
#b::
{
Send ^b
Return
}
In Windows, Alt+Left navigates to the next tab. We want to remap this to navigate to the next word block.
; Navigate to next text block
!Left::
{
Send ^{Left}
Return
}
Since WindowsKey+L locks the workstation, the best way to solve this issue is to add a Shift key, i.e. (⌘+Shift+L).
; Go to Line Number (⌘+Shift+L) -> (Ctrl+G)
#+L::
{
Send ^g
Return
}
; Hide All Windows (⌘+Shift+F12) -> (Ctrl+Shift+F12)
#+F12::
{
Send ^+{F12}
Return
}
; Select Next Tab (⌘+Shift+]) -> (Alt-Right)
#+]::
{
Send !{Right}
Return
}
; Select Previous Tab (⌘+Shift+[) -> (Alt-Left)
#+[::
{
Send !{Left}
Return
}
#1::
{
Send !1
Return
}
#2::
{
Send !2
Return
}
#4::
{
Send !4
Return
}
#5::
{
Send !5
Return
}
#6::
{
Send !6
Return
}
#7::
{
Send !7
Return
}
#9::
{
Send !9
Return
}
; Close Current Tab (⌘+W) -> (Ctrl+F4)
#w::
{
Send ^{F4}
Return
}
Use this alternative and map Windows Key to Meta key in IntelliJ IDEA or Android Studio.
Caveats
The only solution I could find is to re-map the conflicting windows key shortcut and still use AutoHotKey to remap. This solution seems silly but it’s the only way to get around the windows mapping.
For Example: Close current tab
Original Mapping: Meta+W Conflict: Windows Ink Workspace Solution:
Enable Meta Key by navigating to Help->Edit Custom Properties
keymap.windows.as.meta=true
The AutoHotKey can be downloaded here: mac-intellij-android-studio.ahk.