-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathkeybindings.json
570 lines (570 loc) · 17.7 KB
/
keybindings.json
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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
// Visual Studio Code keybindings
//
// Place your key bindings in this file to override the defaults
//
// This emulates (reasonably closely) my Emacs configuration.
// You will need several plugins to make it work:
// - Awesome Emacs Keymap: https://github.com/whitphx/vscode-emacs-mcx
// - clangd: https://github.com/clangd/vscode-clangd
// - CMake: https://github.com/twxs/vs.language.cmake
// - CMake Tools: https://github.com/microsoft/vscode-cmake-tools
// - Code Ace Jumper: https://github.com/lucax88x/CodeAceJumper
// - Code Spell Checker: https://github.com/streetsidesoftware/vscode-spell-checker
// - edamagit: https://github.com/kahole/edamagit
// - Find It Faster: https://github.com/tomrijndorp/vscode-finditfaster
// - Go to Next/Previous Member: https://github.com/mishkinf/vscode-goto-next-previous-member
// - Markdown+Math: https://github.com/goessner/mdmath
// - Output Colorizer: https://github.com/IBM-Cloud/vscode-log-output-colorizer
// - Pylance: https://github.com/microsoft/pylance-release
// - Python: https://github.com/Microsoft/vscode-python
// - Python Debugger: https://github.com/microsoft/vscode-python-debugger
// - marimo notebooks: https://github.com/marimo-team/vscode-marimo
// - Julia: https://github.com/julia-vscode/julia-vscode
// - rust-analyzer: https://github.com/rust-lang/rust-analyzer
// - Selected Lines Count: https://github.com/gurumukhi/vscode-extension-line-count
//
// To explore:
// - Hungry delete: https://github.com/Jasonlhy/VSCode-Hungry-Delete
//
// I don't yet have hydro-like bindings, but this is possible as of 2023:
// https://github.com/Microsoft/vscode/issues/6966
//
// Not related to keybindings, but commit signing with PGP keys
// can be set up. See:
// https://github.com/microsoft/vscode/wiki/Commit-Signing
// You'll need to be aware of the following:
// `defaults write org.gpgtools.common UseKeychain NO`
[
// Allow sending through Emacs close command in terminal mode.
{
"key": "ctrl+x ctrl+c",
"command": "-workbench.action.closeWindow"
},
{
"key": "ctrl+x ctrl+c",
"when": "editorTextFocus",
"command": "workbench.action.closeWindow"
},
// END
// Projectile-like file open. There seems to be no great way to
// open a file without projectile. Cmd+o is the closest, but
// that's quite clumsy.
{
"key": "ctrl+x alt+f",
"command": "workbench.action.quickOpen"
},
{
"key": "cmd+p",
"command": "-workbench.action.quickOpen"
},
// END
// By default Awesome Emacs disables the below in terminal
// windows, which I find annoying.
{
"key": "ctrl+x b",
"command": "-workbench.action.showAllEditorsByMostRecentlyUsed"
},
{
"key": "ctrl+x b",
"command": "workbench.action.showAllEditorsByMostRecentlyUsed"
},
{
"key": "ctrl+x o",
"command": "-workbench.action.navigateEditorGroups"
},
{
"key": "ctrl+x o",
"command": "workbench.action.navigateEditorGroups"
},
// END
// Go to line.
{
"key": "alt+g alt+g",
"command": "workbench.action.gotoLine"
},
{
"key": "ctrl+g",
"command": "-workbench.action.gotoLine"
},
// END
// Use alt+n/p to add cursors on line above or below.
// We also check if we currently have text selected, in
// which case we select the next check of the currently
// selected text.
{
"key": "alt+n",
"command": "editor.action.insertCursorBelow",
"when": "editorTextFocus && !editorHasSelection"
},
{
"key": "alt+n",
"command": "emacs-mcx.addSelectionToNextFindMatch",
"when": "editorTextFocus && editorHasSelection"
},
{
"key": "alt+p",
"command": "editor.action.insertCursorAbove",
"when": "editorTextFocus && !editorHasSelection"
},
{
"key": "alt+p",
"command": "emacs-mcx.addSelectionToPreviousFindMatch",
"when": "editorTextFocus && editorHasSelection"
},
{
"key": "alt+cmd+up",
"command": "-editor.action.insertCursorAbove",
"when": "editorTextFocus"
},
{
"key": "alt+cmd+down",
"command": "-editor.action.insertCursorBelow",
"when": "editorTextFocus"
},
{
"key": "ctrl+c ctrl+f",
"command": "editor.action.formatSelection",
"when": "editorHasDocumentSelectionFormattingProvider && editorTextFocus && !editorReadonly"
},
{
"key": "cmd+k cmd+f",
"command": "-editor.action.formatSelection",
"when": "editorHasDocumentSelectionFormattingProvider && editorTextFocus && !editorReadonly"
},
// END
// Change movement control during popup widget like completion selection
// to meta+n/p instead of ctrl+n/p. Select option using ctrl+m or Enter.
{
"key": "alt+n",
"command": "selectNextSuggestion",
"when": "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus"
},
{
"key": "ctrl+n",
"command": "-selectNextSuggestion",
"when": "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus"
},
{
"key": "alt+p",
"command": "selectPrevSuggestion",
"when": "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus"
},
{
"key": "ctrl+p",
"command": "-selectPrevSuggestion",
"when": "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus"
},
{
"key": "ctrl+m",
"command": "acceptSelectedSuggestion",
"when": "acceptSuggestionOnEnter && suggestWidgetHasFocusedSuggestion && suggestWidgetVisible && suggestionMakesTextEdit && textInputFocus"
},
{
"key": "enter",
"command": "acceptSelectedSuggestion",
"when": "acceptSuggestionOnEnter && suggestWidgetHasFocusedSuggestion && suggestWidgetVisible && suggestionMakesTextEdit && textInputFocus"
},
// END
// Magit config to match Emacs
{
"key": "alt+g alt+s",
"command": "magit.status"
},
{
"key": "alt+x g",
"command": "-magit.status"
},
{
"key": "ctrl+m",
"command": "magit.visit-at-point",
"when": "editorTextFocus && editorLangId == 'magit' && vim.mode =~ /^(?!SearchInProgressMode|CommandlineInProgress).*$/"
},
{
"key": "enter",
"command": "-magit.visit-at-point",
"when": "editorTextFocus && editorLangId == 'magit' && vim.mode =~ /^(?!SearchInProgressMode|CommandlineInProgress).*$/"
},
// Mimic quick window selection in Emacs
{
"key": "alt+1",
"command": "workbench.action.focusFirstEditorGroup",
},
{
"key": "alt+2",
"command": "workbench.action.focusSecondEditorGroup",
},
{
"key": "alt+3",
"command": "workbench.action.focusThirdEditorGroup",
},
{
"key": "alt+4",
"command": "workbench.action.focusFourthEditorGroup",
},
{
"key": "alt+5",
"command": "workbench.action.focusFifthEditorGroup",
},
{
"key": "alt+6",
"command": "workbench.action.focusSixthEditorGroup",
},
{
"key": "alt+7",
"command": "workbench.action.focusSeventhEditorGroup",
},
{
"key": "alt+8",
"command": "workbench.action.focusEighthEditorGroup",
},
{
"key": "ctrl+1",
"command": "-workbench.action.openEditorAtIndex1"
},
{
"key": "ctrl+2",
"command": "-workbench.action.openEditorAtIndex2"
},
{
"key": "ctrl+3",
"command": "-workbench.action.openEditorAtIndex3"
},
{
"key": "ctrl+4",
"command": "-workbench.action.openEditorAtIndex4"
},
{
"key": "ctrl+5",
"command": "-workbench.action.openEditorAtIndex5"
},
{
"key": "ctrl+6",
"command": "-workbench.action.openEditorAtIndex6"
},
{
"key": "ctrl+7",
"command": "-workbench.action.openEditorAtIndex7"
},
{
"key": "ctrl+8",
"command": "-workbench.action.openEditorAtIndex8"
},
{
"key": "ctrl+9",
"command": "-workbench.action.openEditorAtIndex9"
},
// Go to file side bar or close it
{
"key": "alt+0",
"command": "workbench.action.toggleSidebarVisibility",
"when": "!editorTextFocus && !inputFocus"
},
{
"key": "alt+0",
"command": "workbench.view.explorer",
"when": "editorTextFocus"
},
{
"key": "cmd+0",
"command": "-workbench.action.focusSideBar"
},
// END
// Set up Code Ace Jumper shortcut, which works like avy in Emacs
{
"key": "alt+s",
"command": "extension.aceJump",
"when": "editorTextFocus"
},
// END
// Create new file and directory in a sane manner
{
"key": "cmd+n",
"command": "explorer.newFile",
},
{
"key": "cmd+shift+n",
"command": "explorer.newFolder",
},
// END
// Terminal mode page up/down so that navigation isn't slow.
{
"key": "alt+v",
"command": "workbench.action.terminal.scrollUpPage",
"when": "terminalFocus"
},
{
"key": "ctrl+v",
"command": "workbench.action.terminal.scrollDownPage",
"when": "terminalFocus"
},
// END
// Configure terminal and sidebar shortcuts
{
"key": "alt+t",
"command": "workbench.action.terminal.toggleTerminal",
"when": "terminal.active"
},
{
"key": "ctrl+`",
"command": "-workbench.action.terminal.toggleTerminal",
"when": "terminal.active"
},
// END
// Jump to definition and back.
{
"key": "alt+.",
"command": "editor.action.revealDefinition",
"when": "editorHasDefinitionProvider && editorTextFocus"
},
{
"key": "f12",
"command": "-editor.action.revealDefinition",
"when": "editorHasDefinitionProvider && editorTextFocus"
},
{
"key": "alt+,",
"command": "workbench.action.navigateBack",
"when": "canNavigateBack"
},
{
"key": "ctrl+-",
"command": "-workbench.action.navigateBack",
"when": "canNavigateBack"
},
// END
// Scroll through symbols in file
{
"key": "shift+cmd+.",
"command": "editor.action.accessibleViewGoToSymbol",
"when": "accessibilityHelpIsShown && accessibleViewGoToSymbolSupported || accessibleViewGoToSymbolSupported && accessibleViewIsShown"
},
{
"key": "shift+cmd+o",
"command": "-editor.action.accessibleViewGoToSymbol",
"when": "accessibilityHelpIsShown && accessibleViewGoToSymbolSupported || accessibleViewGoToSymbolSupported && accessibleViewIsShown"
},
// END
// Go to a symbol by name
{
"key": "shift+cmd+o",
"command": "workbench.action.gotoSymbol",
"when": "!accessibilityHelpIsShown && !accessibleViewIsShown"
},
{
"key": "shift+cmd+o",
"command": "-workbench.action.gotoSymbol",
"when": "!accessibilityHelpIsShown && !accessibleViewIsShown"
},
// END
// Show docs, etc. at point. This is like lsp-ui-doc
{
"key": "ctrl+c ctrl+i",
"command": "editor.action.showHover",
"when": "editorTextFocus"
},
{
"key": "cmd+k cmd+i",
"command": "-editor.action.showHover",
"when": "editorTextFocus"
},
// END
// Comment/uncomment selected lines
// TODO: would be nice if it was at point.
{
"key": "ctrl+c ;",
"command": "editor.action.commentLine",
"when": "editorTextFocus && !editorReadonly"
},
{
"key": "ctrl+;",
"command": "-editor.action.commentLine",
"when": "editorTextFocus && !editorReadonly"
},
// END
// ripgrep-like behavior with find-it-faster.
// TODO: Enable buffer and pane switching in FIF buffer so it can be
// backgrounded. This is a bit tricky because I think it's technically
// a terminal buffer.
{
"key": "ctrl+c g",
"command": "find-it-faster.findWithinFilesWithType"
},
{
"key": "ctrl+shift+cmd+u",
"command": "-find-it-faster.findWithinFilesWithType"
},
// END
// Navigate up/down or next/previous line with ctrl+n/p
{
"key": "ctrl+p",
"command": "emacs-mcx.previousLine",
"when": "terminalFocus"
},
{
"key": "up",
"command": "-emacs-mcx.previousLine",
"when": "terminalFocus"
},
{
"key": "ctrl+n",
"command": "emacs-mcx.nextLine",
"when": "terminalFocus"
},
{
"key": "down",
"command": "-emacs-mcx.nextLine",
"when": "terminalFocus"
},
{
"key": "ctrl+n",
"command": "emacs-mcx.nextLine",
"when": "editorTextFocus"
},
{
"key": "down",
"command": "-emacs-mcx.nextLine",
"when": "editorTextFocus"
},
{
"key": "ctrl+p",
"command": "emacs-mcx.previousLine",
"when": "editorTextFocus && !suggestWidgetVisible"
},
{
"key": "up",
"command": "-emacs-mcx.previousLine",
"when": "editorTextFocus && !suggestWidgetVisible"
},
// END
// Compile (with CMake) using ctrl+c ctrl+c.
//
// I don't think it's possible to check if a project uses CMake.
// It might even be that vscode requires CMake (or maybe some
// other build systems) be used. In Emacs I bind to CMake if
// the project uses that, to clang/gcc if it's not a project,
// and could set it up for other build systems if they can be
// identified.
{
"key": "ctrl+c ctrl+c",
"command": "cmake.buildWithTarget",
"when": "cmake:enableFullFeatureSet && !cmake:hideBuildCommand && editorLangId != 'git-commit' && editorLangId != 'git-rebase'"
},
{
"key": "shift+f7",
"command": "-cmake.buildWithTarget",
"when": "cmake:enableFullFeatureSet && !cmake:hideBuildCommand"
},
// END
// Hungry-delete or smart backspace.
//
// Also behaves differently from Emacs, but I believe I'd have to
// write my own plugin to make it reasonable. It's still better than
// the default.
{
"key": "backspace",
"command": "-extension.smartBackspace",
"when": "config.hungryDelete.enableSmartBackspace && editorTextFocus && !editorReadonly"
},
{
"key": "alt+backspace",
"command": "-extension.hungryDelete",
"when": "editorTextFocus && !editorReadonly"
},
{
"key": "alt+h",
"command": "emacs-mcx.backwardKillWord",
"when": "editorTextFocus && !config.emacs-mcx.useMetaPrefixMacCmd && !editorReadonly"
},
{
"key": "alt+backspace",
"command": "-emacs-mcx.backwardKillWord",
"when": "editorTextFocus && !config.emacs-mcx.useMetaPrefixMacCmd && !editorReadonly"
},
// END
// Go to end of function/class/member/etc.
//
// It appears vscode doesn't behave like Emacs, but by having slightly
// different behavior in C++ and python, it becomes more reasonably. Python
// is essentially treated as plain text.
{
"key": "ctrl+alt+e",
"command": "gotoNextPreviousMember.nextMember",
"when": "editorTextFocus && editorLangId == cpp",
},
{
"key": "ctrl+down",
"command": "-gotoNextPreviousMember.nextMember"
},
{
"key": "ctrl+alt+a",
"command": "gotoNextPreviousMember.previousMember",
"when": "editorTextFocus && editorLangId == cpp",
},
{
"key": "ctrl+up",
"command": "-gotoNextPreviousMember.previousMember"
},
{
"key": "ctrl+alt+a",
"command": "emacs-mcx.backwardParagraph",
"when": "editorTextFocus && !config.emacs-mcx.useMetaPrefixMacCmd && !suggestWidgetVisible && editorLangId != cpp"
},
{
"key": "ctrl+alt+e",
"command": "emacs-mcx.forwardParagraph",
"when": "editorTextFocus && !config.emacs-mcx.useMetaPrefixMacCmd && !suggestWidgetVisible && editorLangId != cpp"
},
{
"key": "shift+alt+[",
"command": "-emacs-mcx.backwardParagraph",
"when": "editorTextFocus && !config.emacs-mcx.useMetaPrefixMacCmd && !suggestWidgetVisible"
},
{
"key": "shift+cmd+[",
"command": "-emacs-mcx.backwardParagraph",
"when": "config.emacs-mcx.useMetaPrefixMacCmd && editorTextFocus && !suggestWidgetVisible"
},
{
"key": "shift+alt+]",
"command": "-emacs-mcx.forwardParagraph",
"when": "editorTextFocus && !config.emacs-mcx.useMetaPrefixMacCmd && !suggestWidgetVisible"
},
{
"key": "shift+cmd+]",
"command": "-emacs-mcx.forwardParagraph",
"when": "config.emacs-mcx.useMetaPrefixMacCmd && editorTextFocus && !suggestWidgetVisible"
},
// END
// Add key chords for changing case:
// PascalCase (sometimes called CamelCase): C-c c u
// lower_snake_case: C-c c l
// SCREAMING_SNAKE_CASE: C-c c s
{
"key": "ctrl+c c u",
"command": "editor.action.transformToPascalcase",
"when": "!terminalFocus",
},
{
"key": "ctrl+c c l",
"command": "runCommands",
"args": {
"commands": [
"editor.action.transformToSnakecase",
"editor.action.transformToLowercase",
],
},
"when": "!terminalFocus",
},
{
"key": "ctrl+c c s",
"command": "runCommands",
"args": {
"commands": [
"editor.action.transformToSnakecase",
"editor.action.transformToUppercase",
],
},
"when": "!terminalFocus",
},
// END
]