{
  "inherits": "default",
  "comment": "macOS keymap - avoids Ctrl+Shift combos, ASCII control chars (Ctrl+J=LF), and international keyboard conflicts",
  "bindings": [
    {
      "comment": "Ctrl+R -> Redo (Ctrl+Y is Unix yank, Ctrl+Shift+Z produces caron)",
      "key": "r",
      "modifiers": ["ctrl"],
      "action": "redo",
      "args": {},
      "when": "normal"
    },
    {
      "comment": "Ctrl+U -> Delete to line start (Unix readline)",
      "key": "u",
      "modifiers": ["ctrl"],
      "action": "delete_to_line_start",
      "args": {},
      "when": "normal"
    },
    {
      "comment": "Ctrl+K -> Delete to line end (Unix readline)",
      "key": "k",
      "modifiers": ["ctrl"],
      "action": "delete_to_line_end",
      "args": {},
      "when": "normal"
    },
    {
      "comment": "Ctrl+Alt+K -> Delete line (Ctrl+Shift+K doesn't work on Mac)",
      "key": "k",
      "modifiers": ["ctrl", "alt"],
      "action": "delete_line",
      "args": {},
      "when": "normal"
    },
    {
      "comment": "Ctrl+L -> Go to line (frees Ctrl+G for find next)",
      "key": "l",
      "modifiers": ["ctrl"],
      "action": "goto_line",
      "args": {},
      "when": "normal"
    },
    {
      "comment": "Ctrl+T -> Go to symbol in file (Ctrl+Shift+O doesn't work on Mac)",
      "key": "t",
      "modifiers": ["ctrl"],
      "action": "command_palette",
      "args": {"filter": "@"},
      "when": "normal"
    },
    {
      "comment": "Ctrl+- -> Navigate back",
      "key": "-",
      "modifiers": ["ctrl"],
      "action": "navigate_back",
      "args": {},
      "when": "normal"
    },
    {
      "comment": "Ctrl+= -> Navigate forward (Ctrl+Shift+- doesn't work on Mac)",
      "key": "=",
      "modifiers": ["ctrl"],
      "action": "navigate_forward",
      "args": {},
      "when": "normal"
    },
    {
      "comment": "Ctrl+] -> Navigate forward (alternative)",
      "key": "]",
      "modifiers": ["ctrl"],
      "action": "navigate_forward",
      "args": {},
      "when": "normal"
    },
    {
      "comment": "Ctrl+D -> Add selection to next find match (Mac: Cmd+D)",
      "key": "d",
      "modifiers": ["ctrl"],
      "action": "add_cursor_next_match",
      "args": {},
      "when": "normal"
    },
    {
      "comment": "Ctrl+. -> Go to definition (replaces F12)",
      "key": ".",
      "modifiers": ["ctrl"],
      "action": "lsp_goto_definition",
      "args": {},
      "when": "normal"
    },
    {
      "comment": "Ctrl+, -> Find all references (Ctrl+Shift+. doesn't work on Mac)",
      "key": ",",
      "modifiers": ["ctrl"],
      "action": "lsp_references",
      "args": {},
      "when": "normal"
    },
    {
      "comment": "Ctrl+Alt+R -> Rename symbol (Ctrl+Shift+R doesn't work on Mac)",
      "key": "r",
      "modifiers": ["ctrl", "alt"],
      "action": "lsp_rename",
      "args": {},
      "when": "normal"
    },
    {
      "comment": "Ctrl+Alt+Up -> Add cursor above (Mac: Option+Cmd+Up)",
      "key": "Up",
      "modifiers": ["ctrl", "alt"],
      "action": "add_cursor_above",
      "args": {},
      "when": "normal"
    },
    {
      "comment": "Ctrl+Alt+Down -> Add cursor below (Mac: Option+Cmd+Down)",
      "key": "Down",
      "modifiers": ["ctrl", "alt"],
      "action": "add_cursor_below",
      "args": {},
      "when": "normal"
    },
    {
      "comment": "Alt+Up/Down -> Move line/selection (Mac: Option+Up/Down)",
      "key": "Up",
      "modifiers": ["alt"],
      "action": "move_line_up",
      "args": {},
      "when": "normal"
    },
    {
      "key": "Down",
      "modifiers": ["alt"],
      "action": "move_line_down",
      "args": {},
      "when": "normal"
    },
    {
      "comment": "Ctrl+A -> Line start (Mac terminals send this for Home)",
      "key": "a",
      "modifiers": ["ctrl"],
      "action": "move_line_start",
      "args": {},
      "when": "normal"
    },
    {
      "comment": "Ctrl+E -> Line end (Mac terminals send this for End)",
      "key": "e",
      "modifiers": ["ctrl"],
      "action": "move_line_end",
      "args": {},
      "when": "normal"
    },
    {
      "comment": "Shift+Home -> Select to line start (for terminals that send Home correctly)",
      "key": "Home",
      "modifiers": ["shift"],
      "action": "select_line_start",
      "args": {},
      "when": "normal"
    },
    {
      "comment": "Shift+End -> Select to line end (for terminals that send End correctly)",
      "key": "End",
      "modifiers": ["shift"],
      "action": "select_line_end",
      "args": {},
      "when": "normal"
    },
    {
      "comment": "Alt+B -> Word left (standard Emacs/readline)",
      "key": "b",
      "modifiers": ["alt"],
      "action": "move_word_left",
      "args": {},
      "when": "normal"
    },
    {
      "comment": "Alt+F -> Word right (standard Emacs/readline)",
      "key": "f",
      "modifiers": ["alt"],
      "action": "move_word_right",
      "args": {},
      "when": "normal"
    },
    {
      "comment": "Alt+Left -> Word left (VS Code style)",
      "key": "Left",
      "modifiers": ["alt"],
      "action": "move_word_left",
      "args": {},
      "when": "normal"
    },
    {
      "comment": "Alt+Right -> End of word (macOS Option+Right convention; stops at word end, not past trailing whitespace)",
      "key": "Right",
      "modifiers": ["alt"],
      "action": "move_word_end",
      "args": {},
      "when": "normal"
    },
    {
      "key": "Left",
      "modifiers": ["alt", "shift"],
      "action": "select_word_left",
      "args": {},
      "when": "normal"
    },
    {
      "key": "Right",
      "modifiers": ["alt", "shift"],
      "action": "select_word_end",
      "args": {},
      "when": "normal"
    },
    {
      "comment": "Ctrl+Arrow as fallback (works without terminal config)",
      "key": "Left",
      "modifiers": ["ctrl"],
      "action": "move_word_left",
      "args": {},
      "when": "normal"
    },
    {
      "key": "Right",
      "modifiers": ["ctrl"],
      "action": "move_word_end",
      "args": {},
      "when": "normal"
    },
    {
      "comment": "Ctrl+Shift+Arrow -> Select word (matches word movement)",
      "key": "Left",
      "modifiers": ["ctrl", "shift"],
      "action": "select_word_left",
      "args": {},
      "when": "normal"
    },
    {
      "key": "Right",
      "modifiers": ["ctrl", "shift"],
      "action": "select_word_end",
      "args": {},
      "when": "normal"
    },
    {
      "comment": "Ctrl+B -> Toggle sidebar/file explorer (Mac: Cmd+B)",
      "key": "b",
      "modifiers": ["ctrl"],
      "action": "toggle_file_explorer",
      "args": {},
      "when": "normal"
    },
    {
      "key": "b",
      "modifiers": ["ctrl"],
      "action": "focus_editor",
      "args": {},
      "when": "file_explorer"
    },
    {
      "comment": "Ctrl+' -> Next error (replaces F8)",
      "key": "'",
      "modifiers": ["ctrl"],
      "action": "jump_to_next_error",
      "args": {},
      "when": "normal"
    },
    {
      "comment": "Ctrl+; -> Previous error (Ctrl+Shift+' doesn't work on Mac)",
      "key": ";",
      "modifiers": ["ctrl"],
      "action": "jump_to_previous_error",
      "args": {},
      "when": "normal"
    },
    {
      "comment": "Ctrl+Alt+' -> Previous error (alternative)",
      "key": "'",
      "modifiers": ["ctrl", "alt"],
      "action": "jump_to_previous_error",
      "args": {},
      "when": "normal"
    },
    {
      "comment": "Ctrl+\\ -> Toggle keyboard capture (replaces F9)",
      "key": "\\",
      "modifiers": ["ctrl"],
      "action": "toggle_keyboard_capture",
      "args": {},
      "when": "terminal"
    },
    {
      "comment": "Ctrl+/ -> Toggle keyboard capture (German keyboard alternative - \\ is hard to type)",
      "key": "/",
      "modifiers": ["ctrl"],
      "action": "toggle_keyboard_capture",
      "args": {},
      "when": "terminal"
    },
    {
      "comment": "Ctrl+G -> Find next (F3 doesn't work; Ctrl+J is Line Feed in terminals)",
      "key": "g",
      "modifiers": ["ctrl"],
      "action": "find_next",
      "args": {},
      "when": "normal"
    },
    {
      "comment": "Ctrl+Alt+G -> Find previous (pairs with Ctrl+G)",
      "key": "g",
      "modifiers": ["ctrl", "alt"],
      "action": "find_previous",
      "args": {},
      "when": "normal"
    },
    {
      "key": "a",
      "modifiers": ["ctrl"],
      "action": "prompt_move_start",
      "args": {},
      "when": "prompt"
    },
    {
      "key": "e",
      "modifiers": ["ctrl"],
      "action": "prompt_move_end",
      "args": {},
      "when": "prompt"
    },
    {
      "key": "Left",
      "modifiers": ["alt"],
      "action": "prompt_move_word_left",
      "args": {},
      "when": "prompt"
    },
    {
      "key": "Right",
      "modifiers": ["alt"],
      "action": "prompt_move_word_right",
      "args": {},
      "when": "prompt"
    },
    {
      "key": "Left",
      "modifiers": ["ctrl"],
      "action": "prompt_move_word_left",
      "args": {},
      "when": "prompt"
    },
    {
      "key": "Right",
      "modifiers": ["ctrl"],
      "action": "prompt_move_word_right",
      "args": {},
      "when": "prompt"
    },
    {
      "comment": "Ctrl+K -> Delete to prompt end (Unix readline)",
      "key": "k",
      "modifiers": ["ctrl"],
      "action": "prompt_delete_to_line_end",
      "args": {},
      "when": "prompt"
    },
    {
      "comment": "Ctrl+W -> Delete word backward (Unix readline)",
      "key": "w",
      "modifiers": ["ctrl"],
      "action": "prompt_delete_word_backward",
      "args": {},
      "when": "prompt"
    },
    {
      "comment": "Disable Alt+0-9 (Mac international keyboard conflict with special chars)",
      "key": "0",
      "modifiers": ["alt"],
      "action": "noop",
      "args": {},
      "when": "normal"
    },
    {
      "key": "1",
      "modifiers": ["alt"],
      "action": "noop",
      "args": {},
      "when": "normal"
    },
    {
      "key": "2",
      "modifiers": ["alt"],
      "action": "noop",
      "args": {},
      "when": "normal"
    },
    {
      "key": "3",
      "modifiers": ["alt"],
      "action": "noop",
      "args": {},
      "when": "normal"
    },
    {
      "key": "4",
      "modifiers": ["alt"],
      "action": "noop",
      "args": {},
      "when": "normal"
    },
    {
      "key": "5",
      "modifiers": ["alt"],
      "action": "noop",
      "args": {},
      "when": "normal"
    },
    {
      "key": "6",
      "modifiers": ["alt"],
      "action": "noop",
      "args": {},
      "when": "normal"
    },
    {
      "key": "7",
      "modifiers": ["alt"],
      "action": "noop",
      "args": {},
      "when": "normal"
    },
    {
      "key": "8",
      "modifiers": ["alt"],
      "action": "noop",
      "args": {},
      "when": "normal"
    },
    {
      "key": "9",
      "modifiers": ["alt"],
      "action": "noop",
      "args": {},
      "when": "normal"
    }
  ]
}
