Skip to content

Instantly share code, notes, and snippets.

@xiaoland
Created February 10, 2026 11:59
Show Gist options
  • Select an option

  • Save xiaoland/e39ef61b5d73291139a55536e07f8ec7 to your computer and use it in GitHub Desktop.

Select an option

Save xiaoland/e39ef61b5d73291139a55536e07f8ec7 to your computer and use it in GitHub Desktop.
Make your text-control, window / application switching experience consistent across MacOS and Windows.
#Requires AutoHotkey v2.0
#SingleInstance Force
; ============================================================
; macOS-like editing for Windows (AHK v2)
; - Alt ~= Option (word/line operations)
; - Ctrl ~= Command (home/end/document)
; ============================================================
; ----------------------------
; Word navigation (Option+Arrow)
; ----------------------------
!Left::Send "^{Left}" ; move left by word
!Right::Send "^{Right}" ; move right by word
; ----------------------------
; Line navigation (Cmd+Arrow) -> Home/End
; Document navigation (Cmd+Up/Down) -> Ctrl+Home/End
; ----------------------------
^Left::Send "{Home}" ; go to line start
^Right::Send "{End}" ; go to line end
^Up::Send "^{Home}" ; go to document start
^Down::Send "^{End}" ; go to document end
; ----------------------------
; Selection variants (Shift + ...)
; macOS: Shift+Option+Arrow selects by word
; Shift+Cmd+Arrow selects to line edges
; Shift+Cmd+Up/Down selects to doc edges
; ----------------------------
+!Left::Send "+^{Left}" ; select left by word
+!Right::Send "+^{Right}" ; select right by word
+^Left::Send "+{Home}" ; select to line start
+^Right::Send "+{End}" ; select to line end
+^Up::Send "+^{Home}" ; select to doc start
+^Down::Send "+^{End}" ; select to doc end
; ----------------------------
; Deletion (Option+Delete / Option+Backspace)
; ----------------------------
!Delete::Send "^{Delete}" ; delete next word
; Alt+Backspace => delete previous word (robust)
!Backspace::
{
Send "^+{Left}"
Send "{Backspace}"
}
; Selection + deletion (Shift+Option+Delete/Backspace)
+!Delete::Send "+^{Delete}"
; ----------------------------
; "Cmd+Backspace/Delete" line-wise delete
; macOS: Cmd+Backspace deletes to line start
; (Cmd+Delete often deletes to line end in many editors)
; Implemented via selection + delete/backspace.
; ----------------------------
^Backspace::
{
Send "+{Home}" ; select to line start
Send "{Backspace}" ; delete selection
}
^Delete::
{
Send "+{End}" ; select to line end
Send "{Delete}" ; delete selection
}
; Shift+Cmd+Backspace/Delete: extend selection then delete
+^Backspace::
{
Send "+{Home}"
Send "{Backspace}"
}
+^Delete::
{
Send "+{End}"
Send "{Delete}"
}
; ----------------------------
; (Optional) Paragraph navigation
; macOS: Option+Up/Down moves by paragraph
; Many Windows apps support Ctrl+Up/Down for paragraph-ish jumps.
; Enable if it feels right in your editors.
; ----------------------------
;!Up::Send "^{Up}"
;!Down::Send "^{Down}"
;+!Up::Send "+^{Up}"
;+!Down::Send "+^{Down}"
; ----------------------------
; App-switcher
; ----------------------------
global AltTabMode := false
^`::
{
global AltTabMode
if AltTabMode
return
AltTabMode := true
Send "{Alt down}{Tab}"
Hotkey "``", CycleForward, "On"
Hotkey "+``", CycleBackward, "On"
KeyWait "Ctrl"
Hotkey "``", "Off"
Hotkey "+``", "Off"
Send "{Alt up}"
AltTabMode := false
}
CycleForward(*)
{
Send "{Tab}"
}
CycleBackward(*)
{
Send "+{Tab}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment