forked from syl20bnr/spacemacs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
keybindings.el
1128 lines (1066 loc) · 46.3 KB
/
keybindings.el
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
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
;;; keybindings.el --- Spacemacs Defaults Layer key-bindings File
;;
;; Copyright (c) 2012-2024 Sylvain Benner & Contributors
;;
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
;; URL: https://github.com/syl20bnr/spacemacs
;;
;; This file is not part of GNU Emacs.
;;
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;; ---------------------------------------------------------------------------
;; Prefixes
;; ---------------------------------------------------------------------------
;; We define prefix commands only for the sake of which-key
(setq spacemacs/key-binding-prefixes `(,dotspacemacs-emacs-command-key "M-x"
"!" "shell cmd"
"*" "search project w/input"
"/" "search project"
"?" "show keybindings"
"a" "applications"
"ac" "chat"
"ae" "email"
"af" "fun"
"ar" "readers"
"am" "music"
"at" "tools"
"ats" "shells"
"atT" "translate"
"aw" "web-services"
"c" "compile/comments"
"C" "capture/colors"
"e" "errors"
"g" "git/versions-control"
"h" "help"
"hd" "help-describe"
"hP" "profiler"
"hT" "tutorials"
"i" "insertion"
"j" "jump/join/split"
"jj" "avy timer"
"jl" "avy line"
"js" "split sexp"
"jw" "avy word"
"k" "lisp"
"kd" "delete"
"kD" "delete-backward"
"k`" "hybrid"
"m" "major mode commands"
"n" "narrow/numbers"
"N" "navigation"
"o" "user bindings"
"p" "projects"
"q" "quit"
"r" "registers/rings/resume"
"rd" "purpose-toggle-window"
"s" "search/symbol"
"sa" "ag"
"sg" "grep"
"sk" "ack"
"sp" "search project"
"sP" "search project w/input"
"sr" "ripgrep"
"st" "pt"
"sw" "web"
"t" "toggles"
"tC" "colors"
"tE" "editing-styles"
"tEe" "emacs (holy-mode)"
"tEh" "hybrid (hybrid-mode)"
"th" "highlight"
"tm" "modeline"
"tt" "timeclock"
"T" "UI toggles/themes"
"C-t" "other toggles"
"u" "universal arg"
"v" "expand region"
"w" "windows"
"wc" "centered"
"wp" "popup"
"x" "text"
"xa" "align"
"xd" "delete"
"xg" "google-translate"
"xj" "justification"
"xl" "lines"
"xR" "Randomize"
"xt" "transpose"
"xw" "words"
"z" "zoom"))
(apply #'spacemacs/declare-prefix spacemacs/key-binding-prefixes)
;; instantly display current keystrokes in mini buffer
(setq echo-keystrokes 0.02)
;; auto-indent on RET
(define-key global-map (kbd "RET") 'newline-and-indent)
;; improve delete-other-windows
(define-key global-map (kbd "C-x 1") 'spacemacs/toggle-maximize-buffer)
;; adds two spacing modes while preserving just-one-space behaviour
(define-key global-map (kbd "M-SPC") 'cycle-spacing)
;; alternate binding to search next occurrence with isearch without
;; exiting isearch
(define-key isearch-mode-map (kbd "S-<return>") 'isearch-repeat-forward)
(define-key isearch-mode-map (kbd "M-S-<return>") 'isearch-repeat-backward)
;; Escape from isearch-mode("/" and "?" in evil-mode) like vim
(define-key isearch-mode-map (kbd "<escape>") 'isearch-cancel)
;; Make <escape> quit as much as possible
(define-key minibuffer-local-map (kbd "<escape>") 'keyboard-escape-quit)
(define-key minibuffer-local-ns-map (kbd "<escape>") 'keyboard-escape-quit)
(define-key minibuffer-local-completion-map (kbd "<escape>") 'keyboard-escape-quit)
(define-key minibuffer-local-must-match-map (kbd "<escape>") 'keyboard-escape-quit)
(define-key minibuffer-local-isearch-map (kbd "<escape>") 'keyboard-escape-quit)
;; Also bind C-n C-p in minibuffer
(define-key minibuffer-local-map (kbd "C-n") 'next-line-or-history-element)
(define-key minibuffer-local-map (kbd "C-p") 'previous-line-or-history-element)
;; linum margin bindings-------------------------------------------------------
(global-set-key (kbd "<left-margin> <down-mouse-1>") 'spacemacs/md-select-linum)
(global-set-key (kbd "<left-margin> <mouse-1>") 'spacemacs/mu-select-linum)
(global-set-key (kbd "<left-margin> <double-mouse-1>") 'spacemacs/select-current-block)
(global-set-key (kbd "<left-margin> <drag-mouse-1>") 'spacemacs/mu-select-linum)
;; ---------------------------------------------------------------------------
;; spacemacs leader key bindings
;; ---------------------------------------------------------------------------
;; Universal argument ---------------------------------------------------------
(spacemacs/set-leader-keys "u" 'universal-argument)
(when (memq dotspacemacs-editing-style '(vim hybrid))
(define-key universal-argument-map
(kbd (concat dotspacemacs-leader-key " u"))
'universal-argument-more))
;; shell command -------------------------------------------------------------
(spacemacs/set-leader-keys "!" 'shell-command)
;; kmacros --------------------------------------------------------------------
(spacemacs|spacebind
"Operations on rectangular selections of text."
:global
(("K" "Keyboard Macros"
("c" "Counter"
("a" kmacro-add-counter "Increment counter")
("c" kmacro-insert-counter "Insert counter")
("C" kmacro-set-counter "Set counter...")
("f" kmacro-set-format "Set display format..."))
("e" "Edit"
("b" kmacro-bind-to-key "Assign key binding...")
("e" kmacro-edit-macro-repeat "Edit last macro")
("l" kmacro-edit-lossage "Create macro from lossage...")
("n" kmacro-name-last-macro "Name last macro...")
("r" kmacro-to-register "Write macro to register...")
("s" kmacro-step-edit-macro "Step by step edit..."))
("k" kmacro-start-macro-or-insert-counter "Start macro/Insert counter")
("K" kmacro-end-or-call-macro "Stop or Run")
("r" "Ring"
("L" kmacro-view-ring-2nd "Display ring head")
("d" kmacro-delete-ring-head "Delete ring head")
("l" kmacro-call-ring-2nd-repeat "Run 2nd macro in ring")
("n" kmacro-cycle-ring-next "Next in ring")
("p" kmacro-cycle-ring-previous "Previous in ring")
("s" kmacro-swap-ring "Swap first two"))
("v" kmacro-view-macro-repeat "View last macro"))))
;; rectangles ------------------------------------------------------------------
(spacemacs|spacebind
"Operations on rectangular selections of text."
:global
(("C-v" "Rectangles"
("c" close-rectangle "Delete whitespace after")
("d" delete-rectangle "Delete text")
("e" rectangle-exchange-point-and-mark "Go to corner")
("i" copy-rectangle-to-register "Copy into register...")
("k" kill-rectangle "Delete and save")
("l" rectangle-left-char "Move left past EOL")
("m" rectangle-mark-mode "Toggle region as rectangular")
("n" rectangle-next-line "Go to next line past EOL")
("N" rectangle-number-lines "Insert line number")
("o" open-rectangle "Shift text right")
("p" rectangle-previous-line "Go to prev. line past EOL")
("r" rectangle-right-char "Move right past EOL")
("s" string-rectangle "Replace lines with string...")
("x" clear-rectangle "Blank out rectangle")
("y" yank-rectangle "Paste last rectangle"))))
;; applications ---------------------------------------------------------------
(spacemacs/set-leader-keys
"a*" 'calc-dispatch
"ap" 'list-processes
"aP" 'proced
"au" 'undo-tree-visualize)
;; easy pg ----------------------------------------------------------------------
(spacemacs|spacebind
"Encrypt / decrypt files with Easy PG"
:global
(("a" "applications"
("Y" "easy pg"
("d" epa-decrypt-file "Decrypt file to...")
("D" epa-delete-keys "Delete keys...")
("e" epa-encrypt-file "Encrypt file...")
("i" epa-insert-keys "Insert keys...")
("k" epa-list-keys "List keys...")
("K" epa-list-secret-keys "List secret keys...")
("x" epa-export-keys "Export keys...")
("s" "sign"
("f" epa-sign-file "Sign file...")
("m" epa-sign-mail "Sign mail...")
("r" epa-sign-region "Sign region..."))
("v" "verify"
("f" epa-verify-file "Verify file...")
("r" epa-verify-region "Verify region...")
("c" epa-verify-cleartext-in-region "Verify cleartext region..."))))))
;; buffers --------------------------------------------------------------------
(spacemacs|spacebind
"Compare buffers, files and directories."
:global
(("TAB" spacemacs/alternate-buffer "Last buffer")
("b" "Buffers"
("N" "New buffer"
("C-i" make-indirect-buffer "New indirect buffer...")
("f" spacemacs/new-empty-buffer-new-frame "New buffer (new frame)")
("h" spacemacs/new-empty-buffer-left "New buffer (left split)")
("i" clone-indirect-buffer "Clone buffer")
("I" clone-indirect-buffer-other-window-without-purpose "Clone buffer (other window)")
("j" spacemacs/new-empty-buffer-below "New buffer (open below)")
("k" spacemacs/new-empty-buffer-above "New buffer (open above)")
("l" spacemacs/new-empty-buffer-right "New buffer (right split)")
("n" spacemacs/new-empty-buffer "New buffer"))
("1" buffer-to-window-1 "Move buffer to window 1")
("2" buffer-to-window-2 "Move buffer to window 2")
("3" buffer-to-window-3 "Move buffer to window 3")
("4" buffer-to-window-4 "Move buffer to window 4")
("5" buffer-to-window-5 "Move buffer to window 5")
("6" buffer-to-window-6 "Move buffer to window 6")
("7" buffer-to-window-7 "Move buffer to window 7")
("8" buffer-to-window-8 "Move buffer to window 8")
("9" buffer-to-window-9 "Move buffer to window 9")
("C-d" spacemacs/kill-other-buffers "Kill other buffers...")
("C-S-d" spacemacs/kill-matching-buffers-rudely "Kill buffers...")
("d" spacemacs/kill-this-buffer "Kill buffer")
("e" spacemacs/safe-erase-buffer "Erase...")
("h" spacemacs/home "Spacemacs home buffer")
("H" spacemacs/switch-to-help-buffer "Help buffer")
("n" next-buffer "Next buffer")
("m" spacemacs/switch-to-messages-buffer "Messages buffer")
("P" spacemacs/copy-clipboard-to-whole-buffer "Paste and replace buffer")
("p" previous-buffer "Previous buffer")
("R" revert-buffer "Revert buffer...")
("s" spacemacs/switch-to-scratch-buffer "Scratch buffer")
("u" spacemacs/reopen-killed-buffer "Reopen last killed buffer")
("x" kill-buffer-and-window "Kill buffer and close window")
("Y" spacemacs/copy-whole-buffer-to-clipboard "Copy buffer")
("w" read-only-mode "Toggle read-only"))))
;; Cycling settings -----------------------------------------------------------
(spacemacs|define-transient-state theme
:title "Themes Transient State"
:doc "\n[_n_/_<right>_] next [_N_/_p_/_<left>_] previous [_t_/_<up>_] list themes"
:bindings
("n" spacemacs/cycle-spacemacs-theme)
("N" spacemacs/cycle-spacemacs-theme-backward)
("p" spacemacs/cycle-spacemacs-theme-backward)
("t" spacemacs/theme-loader)
("<up>" spacemacs/theme-loader)
("<right>" spacemacs/cycle-spacemacs-theme)
("<left>" spacemacs/cycle-spacemacs-theme-backward))
(spacemacs/set-leader-keys "Tn"
'spacemacs/theme-transient-state/spacemacs/cycle-spacemacs-theme)
(spacemacs/set-leader-keys "TN"
'spacemacs/theme-transient-state/spacemacs/cycle-spacemacs-theme-backward)
;; errors ---------------------------------------------------------------------
(spacemacs/set-leader-keys
"ez" 'spacemacs/last-error
"en" 'spacemacs/next-error
"eN" 'spacemacs/previous-error
"ep" 'spacemacs/previous-error)
(spacemacs|define-transient-state error
:title "Error Transient State"
:hint-is-doc t
:dynamic-hint
(let ((sys (spacemacs/error-delegate)))
(cond
((eq 'flycheck sys)
"\nBrowsing flycheck errors from this buffer.")
((eq 'emacs sys)
(let ((buf (next-error-find-buffer)))
(if buf
(concat "\nBrowsing entries from \""
(buffer-name buf)
"\""
(with-current-buffer buf
(when spacemacs--gne-line-func
(format " (%d of %d)"
(max 1 (1+ (- spacemacs--gne-cur-line
spacemacs--gne-min-line)))
(1+ (- spacemacs--gne-max-line
spacemacs--gne-min-line))))))
"\nNo next-error capable buffer found.")))))
:bindings
("n" spacemacs/next-error "next")
("p" spacemacs/previous-error "prev")
("N" spacemacs/previous-error "prev")
("z" recenter-top-bottom "recenter")
("q" nil "quit" :exit t)
:evil-leader "e.")
;; ediff ----------------------------------------------------------------------
(spacemacs|spacebind
"Compare buffers, files and directories."
:global
(("D" "Diff/Compare"
("b" "Buffers"
("3" ediff-buffers3 "Between 3 buffers...")
("b" ediff-buffers "Between 2 buffers...")
("B" ediff-backup "With backup file...")
("p" ediff-patch-buffer "With a patch..."))
("d" "Directories"
("3" ediff-directories3 "Between 3 directories...")
("d" ediff-directories "Between 2 directories...")
("r" ediff-directory-revisions "Using SCM revisions..."))
("f" "Files"
("." spacemacs/ediff-dotfile-and-template "With Spacemacs dotfile")
("3" ediff-files3 "Between 3 files...")
("f" ediff-files "Between 2 files...")
("p" ediff-patch-file "With a patch...")
("v" ediff-revision "Between file revisions..."))
("m" "Merge"
("b" "Buffers"
("3" ediff-merge-buffers-with-ancestor "3-way merge...")
("b" ediff-merge-buffers "2-way merge..."))
("d" "Directories"
("3" ediff-merge-directories-with-ancestor "3-way merge...")
("d" ediff-merge-directories "2-way merge..."))
("f" "Files"
("3" ediff-merge-files-with-ancestor "3-way merge...")
("f" ediff-merge-files "2-way merge..."))
("r" "Revisions"
("3" ediff-merge-revisions-with-ancestor "3-way merge...")
("r" ediff-merge-revisions "2-way merge...")))
("r" "Regions"
("l" ediff-regions-linewise "Between 2 regions (linewise)...")
("w" ediff-regions-wordwise "Between 2 regions (wordwise)..."))
("w" "Windows"
("l" ediff-windows-linewise "Linewise between visible text...")
("w" ediff-windows-wordwise "Wordwise between visible text..."))
("s" ediff-show-registry "Show registry")
("h" ediff-documentation "Documentation"))))
;; file -----------------------------------------------------------------------
(spacemacs|spacebind
"Files manipulation."
:global
(("f" "Files"
("A" spacemacs/find-file-and-replace-buffer "Set another file for buffer...")
("c" spacemacs/save-as "Save file or active region as a new file...")
("D" spacemacs/delete-current-buffer-file "Delete...")
("i" spacemacs/insert-file "Insert file content...")
("l" find-file-literally "Open file literally...")
("E" spacemacs/sudo-edit "Open using sudo...")
("o" spacemacs/open-file-or-directory-in-external-app "Open with external app")
("R" spacemacs/rename-current-buffer-file "Rename...")
("S" evil-write-all "Save all")
("s" save-buffer "Save")
("C" "Convert"
("d" spacemacs/unix2dos "Convert to DOS")
("u" spacemacs/dos2unix "Convert to UNIX"))
("e" "Emacs/Spacemacs"
("C-e" spacemacs/force-init-spacemacs-env "Recreate env. variables file")
("c" spacemacs/recompile-elpa "Recompile packages")
("i" spacemacs/find-user-init-file "Open Emacs \"init.el\"")
("I" spacemacs/find-user-early-init-file "Open Emacs \"early-init.el\"")
("d" spacemacs/find-dotfile "Open Spacemacs dotfile")
("D" spacemacs/ediff-dotfile-and-template "Diff. with dotfile template")
("e" spacemacs/edit-env "Open \".spacemacs.env\"")
("E" dotspacemacs/call-user-env "Refresh env. variables")
("l" find-library "Find Emacs library...")
("R" dotspacemacs/sync-configuration-layers "Reload configuration")
("v" spacemacs/display-and-copy-version "Copy Spacemacs version")
("U" configuration-layer/update-packages "Update packages..."))
("v" "Variables"
("d" add-dir-local-variable "Add directory-local variable...")
("f" add-file-local-variable "Add bottom file variable...")
("p" add-file-local-variable-prop-line "Add top file property..."))
("y" "Yank/Copy"
("c" spacemacs/copy-file-path-with-line-column "File path with line and column")
("d" spacemacs/copy-directory-path "Directory path")
("l" spacemacs/copy-file-path-with-line "File path with line number")
("n" spacemacs/copy-file-name "File name")
("N" spacemacs/copy-file-name-base "File name without extension")
("y" spacemacs/copy-file-path "File path")
("b" spacemacs/copy-buffer-name "Buffer name")))))
;; frame ----------------------------------------------------------------------
(spacemacs|spacebind
"Frames"
:global
(("F" "Frames"
("f" spacemacs/find-file-other-frame "Find file other frame...")
("d" delete-frame "Delete frame")
("D" delete-other-frames "Delete other frames")
("b" spacemacs/switch-to-buffer-other-frame "Switch to buffer other frame...")
("B" spacemacs/display-buffer-other-frame "Display buffer other frame...")
("o" other-frame "Switch to other frame")
("O" spacemacs/dired-other-frame "Dired other frame...")
("n" make-frame "Make frame"))))
;; help -----------------------------------------------------------------------
(defalias 'emacs-tutorial 'help-with-tutorial)
(spacemacs/set-leader-keys
"hda" 'apropos-command
"hdb" 'describe-bindings
"hdc" 'describe-char
"hdf" 'describe-function
"hdF" 'describe-face
"hdk" 'describe-key
"hdK" 'describe-keymap
"hdl" 'spacemacs/describe-last-keys
"hdm" 'describe-mode
"hdp" 'describe-package
"hdP" 'configuration-layer/describe-package
"hds" 'spacemacs/describe-system-info
"hdt" 'describe-text-properties
"hdT" 'describe-theme
"hdv" 'describe-variable
"hI" 'spacemacs/report-issue
"hn" 'view-emacs-news
"hPs" 'profiler-start
"hPk" 'profiler-stop
"hPr" 'profiler-report
"hPw" 'profiler-report-write-profile
"hTe" 'emacs-tutorial)
;; insert stuff ---------------------------------------------------------------
(spacemacs/set-leader-keys
"iJ" 'spacemacs/insert-line-below-no-indent
"iK" 'spacemacs/insert-line-above-no-indent
"ik" 'spacemacs/evil-insert-line-above
"ij" 'spacemacs/evil-insert-line-below
"ib" 'insert-buffer)
;; format ---------------------------------------------------------------------
(spacemacs/set-leader-keys
"j(" 'check-parens
"j=" 'spacemacs/indent-region-or-buffer
"j+" 'spacemacs/iwb-region-or-buffer
"jo" 'open-line
"jS" 'spacemacs/split-and-new-line
"jk" 'spacemacs/evil-goto-next-line-and-indent)
;; navigation/jumping ---------------------------------------------------------
(spacemacs/set-leader-keys
"j0" 'spacemacs/push-mark-and-goto-beginning-of-line
"j$" 'spacemacs/push-mark-and-goto-end-of-line
"jc" 'goto-last-change
"jf" 'find-function
"jv" 'find-variable)
;; Compilation ----------------------------------------------------------------
(spacemacs/set-leader-keys
"cC" 'compile
"ck" 'kill-compilation
"cr" 'recompile
"cn" 'next-error
"cN" 'previous-error
"cd" 'spacemacs/show-hide-compilation-window
"cb" 'spacemacs/switch-to-compilation-buffer)
(with-eval-after-load 'compile
(evil-define-key 'motion compilation-mode-map (kbd "gf") 'find-file-at-point)
(define-key compilation-mode-map "r" 'recompile)
(define-key compilation-mode-map "g" nil))
;; narrow & widen -------------------------------------------------------------
(spacemacs/set-leader-keys
"nr" 'narrow-to-region
"np" 'narrow-to-page
"nf" 'narrow-to-defun
"nR" 'spacemacs/narrow-to-region-indirect-buffer
"nP" 'spacemacs/narrow-to-page-indirect-buffer
"nF" 'spacemacs/narrow-to-defun-indirect-buffer
"nw" 'widen)
;; toggle ---------------------------------------------------------------------
(spacemacs|add-toggle highlight-current-line-globally
:mode global-hl-line-mode
:documentation "Globally highlight the current line."
:evil-leader "thh")
(spacemacs|add-toggle truncate-lines
:status truncate-lines
:on (toggle-truncate-lines)
:off (toggle-truncate-lines -1)
:documentation "Toggle between line wrapping or truncation (no wrap)."
:evil-leader "tl")
(spacemacs|add-toggle visual-line-navigation
:status visual-line-mode
:on
(progn
(visual-line-mode)
(spacemacs//init-visual-line-keys)
(evil-normalize-keymaps))
:off
(progn
(visual-line-mode -1)
(evil-normalize-keymaps))
:documentation "Move point according to visual lines."
:evil-leader "tL")
(spacemacs|add-toggle visual-line-navigation-globally
:status global-visual-line-mode
:on
(progn
(global-visual-line-mode)
(spacemacs//init-visual-line-keys)
(evil-normalize-keymaps))
:off
(progn
(global-visual-line-mode -1)
(evil-normalize-keymaps))
:documentation "Move point according to visual lines globally."
:evil-leader "t C-S-l")
(spacemacs|add-toggle auto-fill-mode
:status auto-fill-function
:on (auto-fill-mode)
:off (auto-fill-mode -1)
:documentation "Break line beyond `current-fill-column` while editing."
:evil-leader "tF")
(spacemacs|add-toggle debug-on-error
:status debug-on-error
:on (setq debug-on-error t)
:off (setq debug-on-error nil)
:documentation "Toggle display of backtrace when an error happens."
:evil-leader "tD")
(spacemacs|add-toggle fringe
:if (fboundp 'fringe-mode)
:status (not (equal fringe-mode 0))
:on (call-interactively 'fringe-mode)
:off (fringe-mode 0)
:documentation "Display the fringe in GUI mode."
:evil-leader "Tf")
(spacemacs|add-toggle fullscreen-frame
:status (memq (frame-parameter nil 'fullscreen) '(fullscreen fullboth))
:on (spacemacs/toggle-frame-fullscreen)
:off (spacemacs/toggle-frame-fullscreen)
:documentation "Display the current frame in full screen."
:evil-leader "TF")
(spacemacs|add-toggle maximize-frame
:status (eq (frame-parameter nil 'fullscreen) 'maximized)
:on (toggle-frame-maximized)
:off (toggle-frame-maximized)
:documentation "Maximize the current frame."
:evil-leader "TM")
(spacemacs|add-toggle mode-line
:status (not hidden-mode-line-mode)
:on (hidden-mode-line-mode -1)
:off (hidden-mode-line-mode)
:documentation "Toggle the visibility of modeline."
:evil-leader "tmT")
(spacemacs|add-toggle display-time
:mode display-time-mode
:documentation "Display time in modeline."
:evil-leader "tmt")
(spacemacs|add-toggle syntax-highlighting
:mode font-lock-mode
:documentation "Toggle syntax highlighting."
:evil-leader "ths")
(spacemacs|add-toggle zero-based-column-indexing
:documentation "Toggle column indexing starting at 0 versus 1.
This is achieved by the built in functionality available in emacs 26 by changing
the value of the `column-number-indicator-zero-based' variable. Functionality
that does not take into account `column-number-indicator-zero-based' will not
respond to this toggle."
:status (bound-and-true-p column-number-indicator-zero-based)
:on (setq column-number-indicator-zero-based t)
:off (setq column-number-indicator-zero-based nil)
:on-message (concat
"Column indexing starts at 0 (current column is "
(number-to-string (current-column))
")")
:off-message (concat
"Column indexing starts at 1 (current column is "
(number-to-string (1+ (current-column)))
")")
:evil-leader "tz")
(spacemacs|add-toggle transparent-frame
:status nil
:on (spacemacs/toggle-transparency)
:documentation "Make the current frame non-opaque."
:evil-leader "TT")
(spacemacs|add-toggle tool-bar
:if window-system
:mode tool-bar-mode
:documentation "Display the tool bar in GUI mode."
:evil-leader "Tt")
(spacemacs|add-toggle menu-bar
:if window-system
:mode menu-bar-mode
:documentation "Display the menu bar."
:evil-leader "Tm")
(spacemacs|add-toggle gui-elements
:if window-system
:status (or menu-bar-mode tool-bar-mode scroll-bar-mode tooltip-mode)
:on (spacemacs//toggle-gui-elements 1)
:off (spacemacs//toggle-gui-elements 0)
:documentation "Toggle menubar, toolbar, scrollbar, and tooltip modes."
:evil-leader "Tg")
;; quit -----------------------------------------------------------------------
(spacemacs/set-leader-keys
"qs" 'spacemacs/save-buffers-kill-emacs
"qq" 'spacemacs/prompt-kill-emacs
"qQ" 'spacemacs/kill-emacs
"qf" 'spacemacs/frame-killer)
;; timeclock ------------------------------------------------------------------
(spacemacs/set-leader-keys
"ttc" 'timeclock-change
"tte" 'timeclock-workday-elapsed-string
"ttg" 'timeclock-workday-remaining-string
"tti" 'timeclock-in
"ttl" 'timeclock-when-to-leave-string
"ttm" 'timeclock-mode-line-display
"tto" 'timeclock-out
"ttr" 'timeclock-reread-log
"tts" 'timeclock-status-string
"ttu" 'timeclock-update-mode-line
"ttv" 'timeclock-visit-timelog
"ttw" 'timeclock-when-to-leave-string)
;; window ---------------------------------------------------------------------
(defun split-window-below-and-focus ()
"Split the window vertically and focus the new window."
(interactive)
(split-window-below)
(windmove-down)
(when (and (boundp 'golden-ratio-mode)
(symbol-value golden-ratio-mode))
(golden-ratio)))
(defun split-window-right-and-focus ()
"Split the window horizontally and focus the new window."
(interactive)
(split-window-right)
(windmove-right)
(when (and (boundp 'golden-ratio-mode)
(symbol-value golden-ratio-mode))
(golden-ratio)))
(spacemacs/set-leader-keys
"w TAB" 'spacemacs/alternate-window
"w1" 'spacemacs/window-split-single-column
"w2" 'spacemacs/window-split-double-columns
"w3" 'spacemacs/window-split-triple-columns
"w4" 'spacemacs/window-split-grid
"wb" 'spacemacs/switch-to-minibuffer-window
"wd" 'spacemacs/delete-window
"wt" 'spacemacs/toggle-current-window-dedication
"wf" 'follow-mode
"wF" 'make-frame
"wH" 'evil-window-move-far-left
"w <S-left>" 'evil-window-move-far-left
"wh" 'evil-window-left
"w <left>" 'evil-window-left
"wJ" 'evil-window-move-very-bottom
"w <S-down>" 'evil-window-move-very-bottom
"wj" 'evil-window-down
"w <down>" 'evil-window-down
"wK" 'evil-window-move-very-top
"w <S-up>" 'evil-window-move-very-top
"wk" 'evil-window-up
"w <up>" 'evil-window-up
"wL" 'evil-window-move-far-right
"w <S-right>" 'evil-window-move-far-right
"wl" 'evil-window-right
"w <right>" 'evil-window-right
"wm" 'spacemacs/toggle-maximize-buffer
;; "wcc" 'spacemacs/toggle-centered-buffer
;; "wcC" 'spacemacs/toggle-distraction-free
;; "wc." 'spacemacs/centered-buffer-transient-state
"wo" 'other-frame
"wr" 'spacemacs/rotate-windows-forward
"wR" 'spacemacs/rotate-windows-backward
"ws" 'split-window-below
"wS" 'split-window-below-and-focus
"w-" 'split-window-below
"wU" 'winner-redo
"wu" 'winner-undo
"wv" 'split-window-right
"wV" 'split-window-right-and-focus
"ww" 'other-window
"wx" 'kill-buffer-and-window
"w/" 'split-window-right
"w=" 'balance-windows-area
"w+" 'spacemacs/window-layout-toggle
"w_" 'spacemacs/maximize-horizontally
"w|" 'spacemacs/maximize-vertically)
;; text -----------------------------------------------------------------------
(defalias 'count-region 'count-words-region)
(spacemacs/set-leader-keys
"xa%" 'spacemacs/align-repeat-percent
"xa&" 'spacemacs/align-repeat-ampersand
"xa(" 'spacemacs/align-repeat-left-paren
"xa)" 'spacemacs/align-repeat-right-paren
"xa{" 'spacemacs/align-repeat-left-curly-brace
"xa}" 'spacemacs/align-repeat-right-curly-brace
"xa[" 'spacemacs/align-repeat-left-square-brace
"xa]" 'spacemacs/align-repeat-right-square-brace
"xa," 'spacemacs/align-repeat-comma
"xa." 'spacemacs/align-repeat-decimal
"xa:" 'spacemacs/align-repeat-colon
"xa;" 'spacemacs/align-repeat-semicolon
"xa=" 'spacemacs/align-repeat-equal
"xa\\" 'spacemacs/align-repeat-backslash
"xaa" 'align
"xac" 'align-current
"xam" 'spacemacs/align-repeat-math-oper
"xar" 'spacemacs/align-repeat
"xa|" 'spacemacs/align-repeat-bar
"xc" 'count-region
"xd SPC" 'cycle-spacing
"xdl" 'delete-blank-lines
"xdw" 'delete-trailing-whitespace
"xjc" 'set-justification-center
"xjf" 'set-justification-full
"xjl" 'set-justification-left
"xjn" 'set-justification-none
"xjr" 'set-justification-right
"xlc" 'spacemacs/sort-lines-by-column
"xlC" 'spacemacs/sort-lines-by-column-reverse
"xld" 'spacemacs/duplicate-line-or-region
"xlk" 'spacemacs/kill-back-to-indentation
"xlr" 'spacemacs/randomize-lines
"xls" 'spacemacs/sort-lines
"xlS" 'spacemacs/sort-lines-reverse
"xlu" 'spacemacs/uniquify-lines
"xtc" 'transpose-chars
"xte" 'transpose-sexps
"xtl" 'transpose-lines
"xtp" 'transpose-paragraphs
"xts" 'transpose-sentences
"xtw" 'transpose-words
"xU" 'upcase-region
"xu" 'downcase-region
"xwc" 'spacemacs/count-words-analysis
"xwr" 'spacemacs/randomize-words
"x TAB" 'indent-rigidly)
(define-key indent-rigidly-map "h" 'indent-rigidly-left)
(define-key indent-rigidly-map "l" 'indent-rigidly-right)
(define-key indent-rigidly-map "H" 'indent-rigidly-left-to-tab-stop)
(define-key indent-rigidly-map "L" 'indent-rigidly-right-to-tab-stop)
;; shell ----------------------------------------------------------------------
(with-eval-after-load 'shell
(evil-define-key 'insert comint-mode-map [up] 'comint-previous-input)
(evil-define-key 'insert comint-mode-map [down] 'comint-next-input))
;; ---------------------------------------------------------------------------
;; Transient-states
;; ---------------------------------------------------------------------------
;; Buffer transient state
(spacemacs|define-transient-state buffer
:title "Buffer Transient State"
:doc "
[_C-1_.._C-9_] goto nth window [_n_/_<right>_]^^ next buffer [_b_] buffer list
[_1_.._9_] move buffer to nth window [_N_/_p_/_<left>_] previous buffer [_C-d_] bury buffer
[_M-1_.._M-9_] swap buffer w/ nth window [_d_]^^^^ kill buffer [_o_] other window
^^^^ [_z_]^^^^ recenter [_q_] quit"
:bindings
("n" next-buffer)
("<right>" next-buffer)
("p" previous-buffer)
("N" previous-buffer)
("o" other-window)
("<left>" previous-buffer)
("b" (cond ((configuration-layer/layer-used-p 'helm)
(helm-buffers-list))
((configuration-layer/layer-used-p 'ivy)
(ivy-switch-buffer))
((configuration-layer/layer-used-p 'compleseus)
(spacemacs/compleseus-switch-to-buffer))))
("d" spacemacs/kill-this-buffer)
("C-d" bury-buffer)
("z" recenter-top-bottom)
("q" nil :exit t)
("1" move-buffer-window-no-follow-1)
("2" move-buffer-window-no-follow-2)
("3" move-buffer-window-no-follow-3)
("4" move-buffer-window-no-follow-4)
("5" move-buffer-window-no-follow-5)
("6" move-buffer-window-no-follow-6)
("7" move-buffer-window-no-follow-7)
("8" move-buffer-window-no-follow-8)
("9" move-buffer-window-no-follow-9)
("M-1" swap-buffer-window-no-follow-1)
("M-2" swap-buffer-window-no-follow-2)
("M-3" swap-buffer-window-no-follow-3)
("M-4" swap-buffer-window-no-follow-4)
("M-5" swap-buffer-window-no-follow-5)
("M-6" swap-buffer-window-no-follow-6)
("M-7" swap-buffer-window-no-follow-7)
("M-8" swap-buffer-window-no-follow-8)
("M-9" swap-buffer-window-no-follow-9)
("C-1" spacemacs/winum-select-window-1)
("C-2" spacemacs/winum-select-window-2)
("C-3" spacemacs/winum-select-window-3)
("C-4" spacemacs/winum-select-window-4)
("C-5" spacemacs/winum-select-window-5)
("C-6" spacemacs/winum-select-window-6)
("C-7" spacemacs/winum-select-window-7)
("C-8" spacemacs/winum-select-window-8)
("C-9" spacemacs/winum-select-window-9))
(spacemacs/set-leader-keys "b." 'spacemacs/buffer-transient-state/body)
;; end of Buffer Transient State
;; Window Transient State
(defun spacemacs/shrink-window-horizontally (delta)
"Wrap `spacemacs/shrink-window-horizontally'."
(interactive "p")
(shrink-window delta t))
(defun spacemacs/shrink-window (delta)
"Wrap `spacemacs/shrink-window'."
(interactive "p")
(shrink-window delta))
(defun spacemacs/enlarge-window (delta)
"Wrap `spacemacs/enlarge-window'."
(interactive "p")
(enlarge-window delta))
(defun spacemacs/enlarge-window-horizontally (delta)
"Wrap `spacemacs/enlarge-window-horizontally'."
(interactive "p")
(enlarge-window delta t))
(defvar spacemacs--window-ts-full-hint-toggle nil
"Display window transient state documentation.")
(defun spacemacs//window-ts-toggle-hint ()
"Toggle the full hint docstring for the window transient state."
(interactive)
(setq spacemacs--window-ts-full-hint-toggle
(not spacemacs--window-ts-full-hint-toggle)))
(defun spacemacs//window-ts-hint ()
"Return a condensed/full hint for the window transient state"
(concat
" "
(if spacemacs--window-ts-full-hint-toggle
spacemacs--window-ts-full-hint
(concat "[" (propertize "?" 'face 'hydra-face-red) "] help"
spacemacs--window-ts-minified-hint))))
(spacemacs|transient-state-format-hint window
spacemacs--window-ts-minified-hint "\n
Select: _a_ _h_ _j_ _k_ _l_ _w_ _0_.._9_ Move: _H_ _J_ _K_ _L_ _r_ _R_ Split: _s_ _v_ Resize: _[_ _]_ _{_ _}_ _m_ _|_ ___")
(spacemacs|transient-state-format-hint window
spacemacs--window-ts-full-hint
(format "\n[_?_] toggle help
Select^^^^ Move^^^^ Split^^^^^^ Resize^^ Other^^
──────^^^^───────────── ────^^^^──────────── ─────^^^^^^───────────── ──────^^─────────── ─────^^──────────────────
[_j_/_k_] down/up [_J_/_K_] down/up [_s_]^^^^ horizontal [_[_] shrink horiz [_d_] close current
[_h_/_l_] left/right [_H_/_L_] left/right [_S_]^^^^ horiz & follow [_]_] enlarge horiz [_D_] close other
[_0_.._9_] window 0..9 [_r_]^^ rotate fwd [_v_]^^^^ vertical [_{_] shrink verti [_u_] restore prev layout
[_a_]^^ ace-window [_R_]^^ rotate bwd [_V_]^^^^ verti & follow [_}_] enlarge verti [_U_] restore next layout
[_o_]^^ other frame ^^^^ [_m_/_|_/___] maximize %s^^^^^^^^^^^^^^^^^ [_q_] quit
[_w_]^^ other window"
(if (configuration-layer/package-used-p 'golden-ratio)
;; the following strings need to be the same length as:
;; %s^^^^^^^^^^^^^^^^^ (above) to keep the following key aligned
"[_g_] golden-ratio "
"^^ ")))
(spacemacs|define-transient-state window
:title "Window Transient State"
:hint-is-doc t
:dynamic-hint (spacemacs//window-ts-hint)
:bindings
("?" spacemacs//window-ts-toggle-hint)
;; Select
("j" evil-window-down)
("<down>" evil-window-down)
("k" evil-window-up)
("<up>" evil-window-up)
("h" evil-window-left)
("<left>" evil-window-left)
("l" evil-window-right)
("<right>" evil-window-right)
("0" spacemacs/winum-select-window-0)
("1" spacemacs/winum-select-window-1)
("2" spacemacs/winum-select-window-2)
("3" spacemacs/winum-select-window-3)
("4" spacemacs/winum-select-window-4)
("5" spacemacs/winum-select-window-5)
("6" spacemacs/winum-select-window-6)
("7" spacemacs/winum-select-window-7)
("8" spacemacs/winum-select-window-8)
("9" spacemacs/winum-select-window-9)
("a" ace-window)
("o" other-frame)
("w" other-window)
;; Move
("J" evil-window-move-very-bottom)
("<S-down>" evil-window-move-very-bottom)
("K" evil-window-move-very-top)
("<S-up>" evil-window-move-very-top)
("H" evil-window-move-far-left)
("<S-left>" evil-window-move-far-left)
("L" evil-window-move-far-right)
("<S-right>" evil-window-move-far-right)
("r" spacemacs/rotate-windows-forward)
("R" spacemacs/rotate-windows-backward)
;; Split
("s" split-window-below)
("S" split-window-below-and-focus)
("-" split-window-below-and-focus)
("v" split-window-right)
("V" split-window-right-and-focus)
("/" split-window-right-and-focus)
("m" spacemacs/toggle-maximize-buffer)
("|" spacemacs/maximize-vertically)
("_" spacemacs/maximize-horizontally)
;; Resize
("[" spacemacs/shrink-window-horizontally)
("]" spacemacs/enlarge-window-horizontally)
("{" spacemacs/shrink-window)
("}" spacemacs/enlarge-window)
;; Other
("d" delete-window)
("D" delete-other-windows)
("u" winner-undo)
("U" winner-redo)
("q" nil :exit t))
(spacemacs/set-leader-keys
"w." 'spacemacs/window-transient-state/body
"w[" 'spacemacs/window-transient-state/spacemacs/shrink-window-horizontally
"w]" 'spacemacs/window-transient-state/spacemacs/enlarge-window-horizontally
"w{" 'spacemacs/window-transient-state/spacemacs/shrink-window
"w}" 'spacemacs/window-transient-state/spacemacs/enlarge-window)
;; end of Window Transient State
;; Text Transient State
(defun spacemacs/scale-up-or-down-font-size (direction)
"Scale the font. If DIRECTION is positive or zero the font is scaled up,
otherwise it is scaled down."
(interactive)
(let ((scale 0.5))
(if (eq direction 0)
(text-scale-set 0)
(if (< direction 0)
(text-scale-decrease scale)
(text-scale-increase scale)))))
(defun spacemacs/scale-up-font ()
"Scale up the font."
(interactive)
(spacemacs/scale-up-or-down-font-size 1))
(defun spacemacs/scale-down-font ()
"Scale up the font."
(interactive)
(spacemacs/scale-up-or-down-font-size -1))
(defun spacemacs/reset-font-size ()
"Reset the font size."
(interactive)
(spacemacs/scale-up-or-down-font-size 0))
(spacemacs|define-transient-state scale-font
:title "Font Scaling Transient State"
:doc "\n[_+_/_=_/_k_] scale up [_-_/___/_j_] scale down [_0_] reset font [_q_] quit"
:bindings
("+" spacemacs/scale-up-font)
("=" spacemacs/scale-up-font)
("k" spacemacs/scale-up-font)
("-" spacemacs/scale-down-font)
("_" spacemacs/scale-down-font)
("j" spacemacs/scale-down-font)
("0" spacemacs/reset-font-size)
("q" nil :exit t))
(spacemacs/set-leader-keys "zx" 'spacemacs/scale-font-transient-state/body)
;; end of Text Transient State
;; Transparency transient-state
(defun spacemacs/toggle-transparency (&optional frame)
"Toggle between transparent and opaque state for FRAME.
If FRAME is nil, it defaults to the selected frame."