-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkeymap.json
More file actions
176 lines (156 loc) · 6.86 KB
/
keymap.json
File metadata and controls
176 lines (156 loc) · 6.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
[
// No context bindings have the highest precedence. See https://zed.dev/docs/key-bindings#precedence
// For macOS Emacs keybindings, see also https://github.com/zed-industries/zed/blob/main/assets/keymaps/macos/emacs.json
// Unbind ctrl-g everywhere.
// I'm used to hitting it repeatedly in Emacs to cancel things and I expect it to do that consistently everywhere.
// Unfortutately zed defaults ctrl-g to go to line which I rarely use. Extra unfortunately, this has been difficult to
// accomplish and I had to bind various things to ctrl-g in various contexts via trial and error to get it to do what
// I want it to do. I'm sure this is brittle and it certainly is horrible, but it was all that I could come up with
// right now. The best way to see all the places that I had to muck with this is to search for "ctrl-g". I did bind go
// to line to "cmd-g cmd-g" like I have in Emacs.
{ "use_key_equivalents": true, "bindings": { "ctrl-g": null } },
{ "context": "GoToLine > Editor", "use_key_equivalents": true, "bindings": { "ctrl-g": "menu::Cancel" } },
{ "context": "Picker > Editor", "use_key_equivalents": true, "bindings": { "ctrl-g": "menu::Cancel" } },
{
"context": "BufferSearchBar > Editor",
"use_key_equivalents": true,
"bindings": { "ctrl-g": "buffer_search::Dismiss" },
},
{ "context": "Pane > Editor", "use_key_equivalents": true, "bindings": { "ctrl-g": "editor::Cancel" } },
{ "context": "PromptEditor > Editor", "use_key_equivalents": true, "bindings": { "ctrl-g": "editor::Cancel" } },
{ "context": "TabSwitcher > Picker", "use_key_equivalents": true, "bindings": { "ctrl-g": "menu::Cancel" } },
{ "context": "Workspace", "use_key_equivalents": true, "bindings": { "ctrl-g": "menu::Cancel" } },
// Debug Key Context View
{
"context": "Pane > KeyContextView",
"use_key_equivalents": true,
"bindings": {
"cmd-x": "command_palette::Toggle",
"q": "pane::CloseActiveItem",
},
},
// Workspace
{
"context": "Workspace",
"use_key_equivalents": true,
"bindings": {
// Commands
"cmd-x": "command_palette::Toggle",
"ctrl-x ctrl-f": ["task::Spawn", { "task_name": "File Finder", "reveal_target": "center" }],
// Focus
"cmd-space": "workspace::ActivateNextPane",
"cmd-shift-space": "workspace::ActivatePreviousPane",
// Pane pain
"ctrl-x 0": "workspace::CloseInactiveTabsAndPanes",
"ctrl-x 1": "pane::JoinAll",
"ctrl-x 2": "pane::SplitAndMoveUp",
"ctrl-x 3": "pane::SplitAndMoveRight",
},
},
// Pane
{
"context": "Pane",
"use_key_equivalents": true,
"bindings": {
"ctrl-x ctrl-a": "pane::DeploySearch",
},
},
// Buffer Search
{
"context": "BufferSearchBar > Editor",
"use_key_equivalents": true,
"bindings": {
"ctrl-n": "search::SelectNextMatch",
"ctrl-p": "search::SelectPreviousMatch",
"enter": "editor::Cancel",
},
},
// Editor
{
"context": "Editor",
"use_key_equivalents": true,
"bindings": {
// Movement
"cmd-m": ["editor::MoveToBeginningOfLine", { "stop_at_indent": true }],
"cmd-b": "editor::MoveToPreviousWordStart", // See Editor && selection_mode
"cmd-f": "editor::MoveToNextWordEnd", // See Editor && selection_mode
"cmd-a": "editor::MoveToStartOfParagraph",
"cmd-e": "editor::MoveToEndOfParagraph",
"cmd-<": "editor::MoveToBeginning",
"cmd->": "editor::MoveToEnd",
"cmd-ctrl-b": "editor::MoveToEnclosingBracket",
"cmd-ctrl-f": "editor::MoveToEnclosingBracket",
"ctrl-v": ["editor::MovePageDown", { "center_cursor": true }],
"cmd-v": ["editor::MovePageUp", { "center_cursor": true }],
"cmd-g cmd-g": "go_to_line::Toggle",
"cmd-.": "outline::Toggle",
// Selection
"cmd-ctrl-space": "editor::SelectLargerSyntaxNode",
"cmd-ctrl-enter": "editor::SelectAllMatches",
"cmd-ctrl-,": "editor::AddSelectionAbove", // See Editor && selection_mode context: editor::SelectPrevious
"cmd-ctrl-.": "editor::AddSelectionBelow", // See Editor && selection_mode context: editor::SelectNext
// Cut/Copy/Paste
// TODO editor::KillRingCut & editor::KillRingYank when zed groks how a kill ring actually works.
"cmd-w": ["workspace::SendKeystrokes", "cmd-c ctrl-g"], // Emacs transient mark mode deactivates mark after copy
"ctrl-k": "editor::CutToEndOfLine",
"ctrl-w": "editor::Cut",
"ctrl-y": "editor::Paste",
// Delete
"cmd-d": "editor::DeleteToNextWordEnd",
"cmd-h": "editor::DeleteToPreviousWordStart",
"ctrl-shift-h": "editor::DeleteLine",
// Insert
"ctrl-m": "editor::Newline",
"cmd-;": "editor::ToggleComments",
// Mutate
"ctrl-j": ["workspace::SendKeystrokes", "ctrl-p ctrl-j"], // Mimic Emacs join-line behavior
"cmd-q": "editor::Rewrap", // Emacs fill-paragraph
"ctrl-t": "editor::Transpose",
"ctrl-x ctrl-t": "editor::MoveLineUp", // Approximate Emacs transpose-lines
// Undo/Redo
"ctrl-/": "editor::Undo",
"ctrl-?": "editor::Redo",
// Commands
"ctrl-,": "editor::ToggleCodeActions",
"ctrl-.": "editor::ShowCompletions",
"ctrl-i": "editor::Hover",
"cmd-x": "command_palette::Toggle",
"ctrl-x ctrl-f": ["task::Spawn", { "task_name": "File Finder", "reveal_target": "center" }],
"ctrl-x ctrl-r": "file_finder::Toggle",
},
},
{
"context": "Editor && (showing_code_actions || showing_completions)",
"use_key_equivalents": true,
"bindings": {
"ctrl-n": "editor::ContextMenuNext",
"ctrl-p": "editor::ContextMenuPrevious",
},
},
// Editor when selection is active
{
"context": "Editor && selection_mode",
"use_key_equivalents": true,
"bindings": {
// Movement
"cmd-b": "editor::SelectToPreviousWordStart", // See Editor
"cmd-f": "editor::SelectToNextWordEnd", // See Editor
// Selection
"cmd-ctrl-,": "editor::SelectPrevious", // See Editor context: editor::AddSelectionAbove
"cmd-ctrl-.": "editor::SelectNext", // See Editor context: editor::AddSelectionBelow
// Mimic Emacs multiple cursors mark (selection) behavior
// NB! there seems to be a bug where editor::SelectLargerSyntaxNode or editor::SelectAllMatches does not set selection_mode, need to file a bug for that
"ctrl-g": "editor::SetMark", // Mimic Emacs multiple cursors where ctrl-g deactivates mark (selection) if any are active
"ctrl-g ctrl-g": "editor::Cancel", // Mimic Emacs multiple cursors where ctrl-g exits if there is no selection
},
},
// Editor when a prediction is being shown inline
{
"context": "Editor && edit_prediction",
"use_key_equivalents": true,
"bindings": {
// "tab": "editor::Tab", // Let tab be tab for god's sake,
// "ctrl-space": "editor::AcceptEditPrediction" // I'll be explicit when I want the prediction
},
},
]