Sources/OrgCore/Keymap/Presets.swift

2cd54205f32212a32ac7cf2a011c7b019f3745c5
orgstar/Sources/OrgCore/Keymap/Presets.swift

991 lines · 27425 bytes

  1/// The keymaps the app ships. The user's `keymap.toml` is layered on top of the chosen one.
  2public enum KeymapPreset: String, Sendable, CaseIterable {
  3    case emacs, mac, doom
  4
  5    public var title: String {
  6        switch self {
  7        case .emacs: "Emacs"
  8        case .mac: "Mac"
  9        case .doom: "Doom (Vim keys)"
 10        }
 11    }
 12
 13    /// Whether the preset edits modally.
 14    public var isModal: Bool { self == .doom }
 15
 16    public var keymap: Keymap {
 17        var problems: [String] = []
 18        let map = try! Keymap(toml: toml, problems: &problems)
 19        precondition(problems.isEmpty, "preset \(rawValue): \(problems)")
 20        return map
 21    }
 22
 23    public var toml: String {
 24        switch self {
 25        case .emacs: Self.common + Self.emacsBindings
 26        case .mac: Self.common + Self.macBindings
 27        case .doom: Self.doomToml
 28        }
 29    }
 30
 31    /// Doom: the Emacs preset's org bindings in every evil state (as org-mode-map's are), with
 32    /// evil-org's `M-h/j/k/l` forms, then Doom's leader, localleader and evil-org keys.
 33    static var doomToml: String {
 34        var problems: [String] = []
 35        let emacs = try! Keymap(toml: common + emacsBindings, problems: &problems)
 36        let translations: [String: String] = ["<left>": "h", "<right>": "l", "<up>": "k", "<down>": "j"]
 37        var out = ""
 38        func bind(_ keys: String, _ command: String, when: String?, mode: String) {
 39            out += "[[bind]]\nkeys = \"\(keys.replacingOccurrences(of: "\\", with: "\\\\"))\"\ncommand = \"\(command)\"\n"
 40            if let when { out += "when = \"\(when)\"\n" }
 41            out += "mode = \"\(mode)\"\n"
 42        }
 43        for binding in emacs.bindings {
 44            let first = binding.keys[0]
 45            let keys = KeySequence.format(binding.keys)
 46            let orgKey = first.key == "c" && first.modifiers == [.control] || first.key == "x" && first.modifiers == [.control]
 47                || (first.modifiers.contains(.meta) && ["<left>", "<right>", "<up>", "<down>", "RET"].contains(first.key))
 48                || (first.modifiers.contains(.shift) && ["<left>", "<right>", "<up>", "<down>"].contains(first.key))
 49                || (first.modifiers == [.control] && first.key == "RET")
 50                || keys == "M-x"
 51            guard orgKey else { continue }
 52            for mode in ["normal", "insert", "visual"] { bind(keys, binding.command, when: binding.when, mode: mode) }
 53            // evil-org: M-h/j/k/l and M-H/J/K/L in normal, visual and insert.
 54            if binding.keys.count == 1, first.modifiers.contains(.meta), let letter = translations[first.key] {
 55                let shifted = first.modifiers.contains(.shift)
 56                let key = "M-" + (shifted ? letter.uppercased() : letter)
 57                for mode in ["normal", "insert", "visual"] { bind(key, binding.command, when: binding.when, mode: mode) }
 58            }
 59            // Doom: C-S-h/j/k/l are org-shift* in normal and insert.
 60            if binding.keys.count == 1, first.modifiers == [.shift], let letter = translations[first.key] {
 61                for mode in ["normal", "insert"] { bind("C-" + letter.uppercased(), binding.command, when: binding.when, mode: mode) }
 62            }
 63            // evil-org insert state: C-t demotes, C-d promotes.
 64            if binding.keys.count == 1, first.modifiers == [.meta], first.key == "<right>" || first.key == "<left>" {
 65                bind(first.key == "<right>" ? "C-t" : "C-d", binding.command, when: binding.when, mode: "insert")
 66            }
 67        }
 68        return out + doomBindings
 69    }
 70
 71    static let doomBindings = """
 72        # Leader
 73        [[bind]]
 74        keys = "SPC SPC"
 75        command = "app.quick-open"
 76        mode = "normal"
 77        [[bind]]
 78        keys = "SPC q q"
 79        command = "app.quit"
 80        mode = "normal"
 81        [[bind]]
 82        keys = "SPC ."
 83        command = "app.quick-open"
 84        mode = "normal"
 85        [[bind]]
 86        keys = "SPC f f"
 87        command = "app.quick-open"
 88        mode = "normal"
 89        [[bind]]
 90        keys = "SPC f s"
 91        command = "app.save"
 92        mode = "normal"
 93        # Buffers
 94        [[bind]]
 95        keys = "SPC b b"
 96        command = "app.buffer.switch"
 97        mode = "normal"
 98        [[bind]]
 99        keys = "SPC b B"
100        command = "app.buffer.switch"
101        mode = "normal"
102        [[bind]]
103        keys = "SPC ,"
104        command = "app.buffer.switch"
105        mode = "normal"
106        [[bind]]
107        keys = "SPC `"
108        command = "app.buffer.last"
109        mode = "normal"
110        [[bind]]
111        keys = "SPC b k"
112        command = "app.buffer.kill"
113        mode = "normal"
114        [[bind]]
115        keys = "SPC b d"
116        command = "app.buffer.kill"
117        mode = "normal"
118        [[bind]]
119        keys = "SPC b K"
120        command = "app.buffer.kill-all"
121        mode = "normal"
122        [[bind]]
123        keys = "SPC b O"
124        command = "app.buffer.kill-others"
125        mode = "normal"
126        [[bind]]
127        keys = "SPC b n"
128        command = "app.buffer.next"
129        mode = "normal"
130        [[bind]]
131        keys = "SPC b p"
132        command = "app.buffer.previous"
133        mode = "normal"
134        [[bind]]
135        keys = "SPC b ]"
136        command = "app.buffer.next"
137        mode = "normal"
138        [[bind]]
139        keys = "SPC b ["
140        command = "app.buffer.previous"
141        mode = "normal"
142        [[bind]]
143        keys = "] b"
144        command = "app.buffer.next"
145        mode = "normal"
146        [[bind]]
147        keys = "[ b"
148        command = "app.buffer.previous"
149        mode = "normal"
150        [[bind]]
151        keys = "SPC b s"
152        command = "app.save"
153        mode = "normal"
154        [[bind]]
155        keys = "SPC b S"
156        command = "app.save-all"
157        mode = "normal"
158        [[bind]]
159        keys = "SPC s s"
160        command = "edit.find"
161        mode = "normal"
162        [[bind]]
163        keys = "SPC /"
164        command = "app.search"
165        mode = "normal"
166        [[bind]]
167        keys = "SPC s p"
168        command = "app.search"
169        mode = "normal"
170        [[bind]]
171        keys = "SPC :"
172        command = "app.palette"
173        mode = "normal"
174        [[bind]]
175        keys = "SPC o a"
176        command = "app.agenda"
177        mode = "normal"
178        [[bind]]
179        keys = "SPC X"
180        command = "app.capture"
181        mode = "normal"
182        [[bind]]
183        keys = "SPC z t"
184        command = "app.clock.report"
185        mode = "normal"
186        [[bind]]
187        keys = "SPC h r r"
188        command = "app.reload-keymap"
189        mode = "normal"
190
191        # Localleader (SPC m)
192        [[bind]]
193        keys = "SPC m t"
194        command = "org.todo.cycle"
195        mode = "normal"
196        [[bind]]
197        keys = "SPC m q"
198        command = "org.tags.set"
199        mode = "normal"
200        [[bind]]
201        keys = "SPC m x"
202        command = "org.checkbox.toggle"
203        mode = "normal"
204        [[bind]]
205        keys = "SPC m A"
206        command = "app.archive"
207        mode = "normal"
208        [[bind]]
209        keys = "SPC m e h h"
210        command = "app.export.html"
211        mode = "normal"
212        [[bind]]
213        keys = "SPC m e h o"
214        command = "app.export.html-open"
215        mode = "normal"
216        [[bind]]
217        keys = "SPC m e m m"
218        command = "app.export.markdown"
219        mode = "normal"
220        [[bind]]
221        keys = "SPC m e l p"
222        command = "app.export.pdf"
223        mode = "normal"
224        [[bind]]
225        keys = "SPC m d d"
226        command = "org.deadline"
227        mode = "normal"
228        [[bind]]
229        keys = "SPC m d s"
230        command = "org.schedule"
231        mode = "normal"
232        [[bind]]
233        keys = "SPC m d t"
234        command = "org.timestamp.active"
235        mode = "normal"
236        [[bind]]
237        keys = "SPC m d T"
238        command = "org.timestamp.inactive"
239        mode = "normal"
240        [[bind]]
241        keys = "SPC m r r"
242        command = "app.refile"
243        mode = "normal"
244        [[bind]]
245        keys = "SPC m s r"
246        command = "app.refile"
247        mode = "normal"
248        [[bind]]
249        keys = "SPC m s A"
250        command = "app.archive"
251        mode = "normal"
252        [[bind]]
253        keys = "SPC m s h"
254        command = "org.subtree.promote"
255        mode = "normal"
256        [[bind]]
257        keys = "SPC m s l"
258        command = "org.subtree.demote"
259        mode = "normal"
260        [[bind]]
261        keys = "SPC m s j"
262        command = "org.subtree.down"
263        mode = "normal"
264        [[bind]]
265        keys = "SPC m s k"
266        command = "org.subtree.up"
267        mode = "normal"
268        [[bind]]
269        keys = "SPC m c i"
270        command = "app.clock.in"
271        mode = "normal"
272        [[bind]]
273        keys = "SPC m c o"
274        command = "app.clock.out"
275        mode = "normal"
276        [[bind]]
277        keys = "SPC m c c"
278        command = "app.clock.cancel"
279        mode = "normal"
280        [[bind]]
281        keys = "SPC m c g"
282        command = "app.clock.goto"
283        mode = "normal"
284        [[bind]]
285        keys = "SPC m c R"
286        command = "app.clock.report"
287        mode = "normal"
288        [[bind]]
289        keys = "SPC m p u"
290        command = "org.priority.up"
291        mode = "normal"
292        [[bind]]
293        keys = "SPC m p d"
294        command = "org.priority.down"
295        mode = "normal"
296        [[bind]]
297        keys = "SPC m b -"
298        command = "org.table.insert-hline"
299        mode = "normal"
300        [[bind]]
301        keys = "SPC m b a"
302        command = "org.table.align"
303        mode = "normal"
304        [[bind]]
305        keys = "SPC m b r"
306        command = "org.table.recalc-all"
307        mode = "normal"
308        [[bind]]
309        keys = "SPC m b d c"
310        command = "org.table.delete-column"
311        mode = "normal"
312        [[bind]]
313        keys = "SPC m b d r"
314        command = "org.table.kill-row"
315        mode = "normal"
316        [[bind]]
317        keys = "SPC m b i c"
318        command = "org.table.insert-column"
319        mode = "normal"
320        [[bind]]
321        keys = "SPC m b i r"
322        command = "org.table.insert-row"
323        mode = "normal"
324        [[bind]]
325        keys = "SPC m b i h"
326        command = "org.table.insert-hline"
327        mode = "normal"
328
329        # evil-org and Doom's org keys
330        [[bind]]
331        keys = "TAB"
332        command = "org.cycle"
333        mode = "normal"
334        [[bind]]
335        keys = "S-TAB"
336        command = "org.cycle-global"
337        mode = "normal"
338        [[bind]]
339        keys = "RET"
340        command = "org.dwim"
341        mode = "normal"
342        [[bind]]
343        keys = "z a"
344        command = "org.cycle"
345        mode = "normal"
346        [[bind]]
347        keys = "z c"
348        command = "org.cycle"
349        mode = "normal"
350        [[bind]]
351        keys = "z o"
352        command = "org.cycle"
353        mode = "normal"
354        [[bind]]
355        keys = "z A"
356        command = "org.cycle-global"
357        mode = "normal"
358        [[bind]]
359        keys = "g h"
360        command = "org.heading.up"
361        mode = "normal"
362        [[bind]]
363        keys = "g j"
364        command = "org.heading.forward-same-level"
365        mode = "normal"
366        [[bind]]
367        keys = "g k"
368        command = "org.heading.backward-same-level"
369        mode = "normal"
370        [[bind]]
371        keys = "] h"
372        command = "org.heading.forward-same-level"
373        mode = "normal"
374        [[bind]]
375        keys = "[ h"
376        command = "org.heading.backward-same-level"
377        mode = "normal"
378        [[bind]]
379        keys = "RET"
380        command = "org.table.next-row"
381        when = "table"
382        mode = "insert"
383        [[bind]]
384        keys = "TAB"
385        command = "org.cycle"
386        mode = "visual"
387        [[bind]]
388        keys = "S-TAB"
389        command = "org.cycle-global"
390        mode = "visual"
391
392        # Insert state: org-cycle and org-shifttab with Doom's +org-indent-maybe-h, which
393        # demotes or promotes a heading and indents or outdents an item tree.
394        [[bind]]
395        keys = "S-TAB"
396        command = "org.cycle-global"
397        mode = "insert"
398        [[bind]]
399        keys = "TAB"
400        command = "org.table.next-field"
401        when = "table"
402        mode = "insert"
403        [[bind]]
404        keys = "S-TAB"
405        command = "org.table.previous-field"
406        when = "table"
407        mode = "insert"
408        [[bind]]
409        keys = "TAB"
410        command = "org.item.indent-tree"
411        when = "item"
412        mode = "insert"
413        [[bind]]
414        keys = "S-TAB"
415        command = "org.item.outdent-tree"
416        when = "item"
417        mode = "insert"
418        [[bind]]
419        keys = "TAB"
420        command = "org.heading.demote"
421        when = "heading"
422        mode = "insert"
423        [[bind]]
424        keys = "S-TAB"
425        command = "org.heading.promote"
426        when = "heading"
427        mode = "insert"
428
429        """
430
431
432    static let common = """
433        [[bind]]
434        keys = "TAB"
435        command = "org.cycle"
436        when = "heading"
437
438        [[bind]]
439        keys = "S-TAB"
440        command = "org.cycle-global"
441        [[bind]]
442        keys = "TAB"
443        command = "org.table.next-field"
444        when = "table"
445        [[bind]]
446        keys = "S-TAB"
447        command = "org.table.previous-field"
448        when = "table"
449        [[bind]]
450        keys = "RET"
451        command = "org.table.next-row"
452        when = "table"
453
454        """
455
456    static let emacsBindings = """
457        # Movement and editing. With a mark set (C-SPC), movement extends the region.
458        [[bind]]
459        keys = "C-f"
460        command = "edit.forward-char"
461        [[bind]]
462        keys = "C-b"
463        command = "edit.backward-char"
464        [[bind]]
465        keys = "C-n"
466        command = "edit.next-line"
467        [[bind]]
468        keys = "C-p"
469        command = "edit.previous-line"
470        [[bind]]
471        keys = "C-a"
472        command = "edit.beginning-of-line"
473        [[bind]]
474        keys = "C-e"
475        command = "edit.end-of-line"
476        [[bind]]
477        keys = "M-f"
478        command = "edit.forward-word"
479        [[bind]]
480        keys = "M-b"
481        command = "edit.backward-word"
482        [[bind]]
483        keys = "M-<"
484        command = "edit.beginning-of-buffer"
485        [[bind]]
486        keys = "M->"
487        command = "edit.end-of-buffer"
488        [[bind]]
489        keys = "C-v"
490        command = "edit.scroll-up"
491        [[bind]]
492        keys = "M-v"
493        command = "edit.scroll-down"
494        [[bind]]
495        keys = "C-l"
496        command = "edit.recenter"
497        [[bind]]
498        keys = "C-d"
499        command = "edit.delete-char"
500        [[bind]]
501        keys = "M-d"
502        command = "edit.kill-word"
503        [[bind]]
504        keys = "M-DEL"
505        command = "edit.backward-kill-word"
506        [[bind]]
507        keys = "C-k"
508        command = "edit.kill-line"
509        [[bind]]
510        keys = "C-y"
511        command = "edit.yank"
512        [[bind]]
513        keys = "C-SPC"
514        command = "edit.set-mark"
515        [[bind]]
516        keys = "C-x h"
517        command = "edit.select-all"
518        [[bind]]
519        keys = "C-w"
520        command = "edit.kill-region"
521        [[bind]]
522        keys = "M-w"
523        command = "edit.copy-region"
524        [[bind]]
525        keys = "C-/"
526        command = "edit.undo"
527        [[bind]]
528        keys = "C-_"
529        command = "edit.undo"
530        [[bind]]
531        keys = "C-x u"
532        command = "edit.undo"
533        [[bind]]
534        keys = "C-g"
535        command = "edit.keyboard-quit"
536        [[bind]]
537        keys = "C-t"
538        command = "edit.transpose-chars"
539        [[bind]]
540        keys = "C-s"
541        command = "edit.find"
542        [[bind]]
543        keys = "C-r"
544        command = "edit.find"
545        [[bind]]
546        keys = "M-%"
547        command = "edit.replace"
548
549        # Files and commands
550        [[bind]]
551        keys = "C-x C-s"
552        command = "app.save"
553        [[bind]]
554        keys = "C-c C-o"
555        command = "org.link.open"
556        [[bind]]
557        keys = "C-x b"
558        command = "app.buffer.switch"
559        [[bind]]
560        keys = "C-x C-b"
561        command = "app.buffer.switch"
562        [[bind]]
563        keys = "C-x k"
564        command = "app.buffer.kill"
565        [[bind]]
566        keys = "C-x <right>"
567        command = "app.buffer.next"
568        [[bind]]
569        keys = "C-x <left>"
570        command = "app.buffer.previous"
571        [[bind]]
572        keys = "C-x s"
573        command = "app.save-all"
574        [[bind]]
575        keys = "C-x C-f"
576        command = "app.quick-open"
577        [[bind]]
578        keys = "M-x"
579        command = "app.palette"
580        [[bind]]
581        keys = "C-c a"
582        command = "app.agenda"
583        [[bind]]
584        keys = "C-c c"
585        command = "app.capture"
586        [[bind]]
587        keys = "C-c C-x C-i"
588        command = "app.clock.in"
589        [[bind]]
590        keys = "C-c C-x C-o"
591        command = "app.clock.out"
592        [[bind]]
593        keys = "C-c C-x C-q"
594        command = "app.clock.cancel"
595        [[bind]]
596        keys = "C-c C-x C-j"
597        command = "app.clock.goto"
598        [[bind]]
599        keys = "C-c C-e h h"
600        command = "app.export.html"
601        [[bind]]
602        keys = "C-c C-e h o"
603        command = "app.export.html-open"
604        [[bind]]
605        keys = "C-c C-e m m"
606        command = "app.export.markdown"
607        [[bind]]
608        keys = "C-c C-e l p"
609        command = "app.export.pdf"
610        [[bind]]
611        keys = "C-c C-e l l"
612        command = "app.export.latex"
613        [[bind]]
614        keys = "C-c C-e o o"
615        command = "app.export.odt"
616        [[bind]]
617        keys = "C-c C-e t u"
618        command = "app.export.text"
619
620        # Org
621        [[bind]]
622        keys = "C-c C-t"
623        command = "org.todo.cycle"
624        [[bind]]
625        keys = "S-<right>"
626        command = "org.todo.cycle"
627        when = "heading"
628        [[bind]]
629        keys = "S-<up>"
630        command = "org.priority.up"
631        when = "heading"
632        [[bind]]
633        keys = "S-<down>"
634        command = "org.priority.down"
635        when = "heading"
636        [[bind]]
637        keys = "M-<left>"
638        command = "org.heading.promote"
639        when = "heading"
640        [[bind]]
641        keys = "M-<right>"
642        command = "org.heading.demote"
643        when = "heading"
644        [[bind]]
645        keys = "M-S-<left>"
646        command = "org.subtree.promote"
647        when = "heading"
648        [[bind]]
649        keys = "M-S-<right>"
650        command = "org.subtree.demote"
651        when = "heading"
652        [[bind]]
653        keys = "M-<up>"
654        command = "org.subtree.up"
655        when = "heading"
656        [[bind]]
657        keys = "M-<down>"
658        command = "org.subtree.down"
659        when = "heading"
660        [[bind]]
661        keys = "M-RET"
662        command = "org.heading.insert"
663        [[bind]]
664        keys = "C-RET"
665        command = "org.heading.insert-after-subtree"
666        [[bind]]
667        keys = "M-S-RET"
668        command = "org.heading.insert-todo"
669        [[bind]]
670        keys = "C-c C-n"
671        command = "org.heading.next"
672        [[bind]]
673        keys = "C-c C-p"
674        command = "org.heading.previous"
675        [[bind]]
676        keys = "C-c C-f"
677        command = "org.heading.forward-same-level"
678        [[bind]]
679        keys = "C-c C-b"
680        command = "org.heading.backward-same-level"
681        [[bind]]
682        keys = "C-c C-u"
683        command = "org.heading.up"
684        [[bind]]
685        keys = "C-c C-q"
686        command = "org.tags.set"
687        [[bind]]
688        keys = "M-RET"
689        command = "org.item.insert"
690        when = "item"
691        [[bind]]
692        keys = "M-S-RET"
693        command = "org.item.insert-checkbox"
694        when = "item"
695        [[bind]]
696        keys = "M-<left>"
697        command = "org.item.outdent"
698        when = "item"
699        [[bind]]
700        keys = "M-<right>"
701        command = "org.item.indent"
702        when = "item"
703        [[bind]]
704        keys = "M-S-<left>"
705        command = "org.item.outdent-tree"
706        when = "item"
707        [[bind]]
708        keys = "M-S-<right>"
709        command = "org.item.indent-tree"
710        when = "item"
711        [[bind]]
712        keys = "M-<up>"
713        command = "org.item.up"
714        when = "item"
715        [[bind]]
716        keys = "M-<down>"
717        command = "org.item.down"
718        when = "item"
719        [[bind]]
720        keys = "C-c C-c"
721        command = "org.checkbox.toggle"
722        when = "item"
723        [[bind]]
724        keys = "C-c C-x C-b"
725        command = "org.checkbox.toggle"
726        [[bind]]
727        keys = "C-c C-w"
728        command = "app.refile"
729        [[bind]]
730        keys = "C-c C-x C-s"
731        command = "app.archive"
732        [[bind]]
733        keys = "C-c $"
734        command = "app.archive"
735        [[bind]]
736        keys = "C-c ."
737        command = "org.timestamp.active"
738        [[bind]]
739        keys = "C-c !"
740        command = "org.timestamp.inactive"
741        [[bind]]
742        keys = "C-c C-s"
743        command = "org.schedule"
744        [[bind]]
745        keys = "C-c C-d"
746        command = "org.deadline"
747        [[bind]]
748        keys = "M-q"
749        command = "org.fill-paragraph"
750        [[bind]]
751        keys = "C-c C-c"
752        command = "org.table.align"
753        when = "table"
754        [[bind]]
755        keys = "C-c C-c"
756        command = "org.table.recalc-all"
757        when = "tblfm"
758        [[bind]]
759        keys = "C-c *"
760        command = "org.table.recalc"
761        when = "table"
762        [[bind]]
763        keys = "C-c C-c"
764        command = "org.babel.execute"
765        when = "src"
766        [[bind]]
767        keys = "M-<up>"
768        command = "org.table.row-up"
769        when = "table"
770        [[bind]]
771        keys = "M-<down>"
772        command = "org.table.row-down"
773        when = "table"
774        [[bind]]
775        keys = "M-<left>"
776        command = "org.table.column-left"
777        when = "table"
778        [[bind]]
779        keys = "M-<right>"
780        command = "org.table.column-right"
781        when = "table"
782        [[bind]]
783        keys = "M-S-<right>"
784        command = "org.table.insert-column"
785        when = "table"
786        [[bind]]
787        keys = "M-S-<left>"
788        command = "org.table.delete-column"
789        when = "table"
790        [[bind]]
791        keys = "M-S-<up>"
792        command = "org.table.kill-row"
793        when = "table"
794        [[bind]]
795        keys = "M-S-<down>"
796        command = "org.table.insert-row"
797        when = "table"
798        [[bind]]
799        keys = "C-c -"
800        command = "org.table.insert-hline"
801        when = "table"
802        [[bind]]
803        keys = "C-c |"
804        command = "org.table.create"
805        [[bind]]
806        keys = "S-<up>"
807        command = "org.timestamp.up"
808        when = "timestamp"
809        [[bind]]
810        keys = "S-<down>"
811        command = "org.timestamp.down"
812        when = "timestamp"
813        [[bind]]
814        keys = "S-<right>"
815        command = "org.timestamp.day-later"
816        when = "timestamp"
817        [[bind]]
818        keys = "S-<left>"
819        command = "org.timestamp.day-earlier"
820        when = "timestamp"
821
822        """
823
824    /// Standard Mac text keys stay as they are; org commands use Control-Command chords, which
825    /// macOS text editing leaves free.
826    static let macBindings = """
827        [[bind]]
828        keys = "C-TAB"
829        command = "app.buffer.next"
830        [[bind]]
831        keys = "C-S-TAB"
832        command = "app.buffer.previous"
833        [[bind]]
834        keys = "C-s-t"
835        command = "org.todo.cycle"
836        [[bind]]
837        keys = "C-s-<up>"
838        command = "org.priority.up"
839        [[bind]]
840        keys = "C-s-<down>"
841        command = "org.priority.down"
842        [[bind]]
843        keys = "C-s-<left>"
844        command = "org.heading.promote"
845        [[bind]]
846        keys = "C-s-<right>"
847        command = "org.heading.demote"
848        [[bind]]
849        keys = "C-M-s-<left>"
850        command = "org.subtree.promote"
851        [[bind]]
852        keys = "C-M-s-<right>"
853        command = "org.subtree.demote"
854        [[bind]]
855        keys = "C-M-s-<up>"
856        command = "org.subtree.up"
857        [[bind]]
858        keys = "C-M-s-<down>"
859        command = "org.subtree.down"
860        [[bind]]
861        keys = "s-RET"
862        command = "org.heading.insert"
863        [[bind]]
864        keys = "C-s-RET"
865        command = "org.heading.insert-after-subtree"
866        [[bind]]
867        keys = "s-S-RET"
868        command = "org.heading.insert-todo"
869        [[bind]]
870        keys = "M-s-<down>"
871        command = "org.heading.next"
872        [[bind]]
873        keys = "M-s-<up>"
874        command = "org.heading.previous"
875        [[bind]]
876        keys = "C-s-q"
877        command = "org.tags.set"
878        [[bind]]
879        keys = "s-RET"
880        command = "org.item.insert"
881        when = "item"
882        [[bind]]
883        keys = "s-S-RET"
884        command = "org.item.insert-checkbox"
885        when = "item"
886        [[bind]]
887        keys = "C-s-<left>"
888        command = "org.item.outdent"
889        when = "item"
890        [[bind]]
891        keys = "C-s-<right>"
892        command = "org.item.indent"
893        when = "item"
894        [[bind]]
895        keys = "C-M-s-<left>"
896        command = "org.item.outdent-tree"
897        when = "item"
898        [[bind]]
899        keys = "C-M-s-<right>"
900        command = "org.item.indent-tree"
901        when = "item"
902        [[bind]]
903        keys = "C-M-s-<up>"
904        command = "org.item.up"
905        when = "item"
906        [[bind]]
907        keys = "C-M-s-<down>"
908        command = "org.item.down"
909        when = "item"
910        [[bind]]
911        keys = "C-s-c"
912        command = "org.checkbox.toggle"
913        [[bind]]
914        keys = "C-s-w"
915        command = "app.refile"
916        [[bind]]
917        keys = "C-s-a"
918        command = "app.archive"
919        [[bind]]
920        keys = "C-s-."
921        command = "org.timestamp.active"
922        [[bind]]
923        keys = "C-M-s-."
924        command = "org.timestamp.inactive"
925        [[bind]]
926        keys = "C-s-s"
927        command = "org.schedule"
928        [[bind]]
929        keys = "C-s-d"
930        command = "org.deadline"
931        [[bind]]
932        keys = "C-s-p"
933        command = "org.fill-paragraph"
934        [[bind]]
935        keys = "C-s-<up>"
936        command = "org.table.row-up"
937        when = "table"
938        [[bind]]
939        keys = "C-s-<down>"
940        command = "org.table.row-down"
941        when = "table"
942        [[bind]]
943        keys = "C-s-<left>"
944        command = "org.table.column-left"
945        when = "table"
946        [[bind]]
947        keys = "C-s-<right>"
948        command = "org.table.column-right"
949        when = "table"
950        [[bind]]
951        keys = "C-M-s-<right>"
952        command = "org.table.insert-column"
953        when = "table"
954        [[bind]]
955        keys = "C-M-s-<left>"
956        command = "org.table.delete-column"
957        when = "table"
958        [[bind]]
959        keys = "C-M-s-<up>"
960        command = "org.table.kill-row"
961        when = "table"
962        [[bind]]
963        keys = "C-M-s-<down>"
964        command = "org.table.insert-row"
965        when = "table"
966        [[bind]]
967        keys = "C-s--"
968        command = "org.table.insert-hline"
969        when = "table"
970        [[bind]]
971        keys = "C-s-\\\\"
972        command = "org.table.create"
973        [[bind]]
974        keys = "C-s-<up>"
975        command = "org.timestamp.up"
976        when = "timestamp"
977        [[bind]]
978        keys = "C-s-<down>"
979        command = "org.timestamp.down"
980        when = "timestamp"
981        [[bind]]
982        keys = "C-s-<right>"
983        command = "org.timestamp.day-later"
984        when = "timestamp"
985        [[bind]]
986        keys = "C-s-<left>"
987        command = "org.timestamp.day-earlier"
988        when = "timestamp"
989
990        """
991}
Keyboard shortcuts

Global

⌘K
Command palette & jump
/
Focus search
?
Show this help
g d
Dashboard
g e
Explore repositories
g n
Notifications

Repository & editor

t
Find file in repository
y
Copy immutable SHA permalink
g c
Code tab
g i
Issues tab
g m
Merge requests tab
g b
Builds tab
⌘↵
Submit active form