summaryrefslogtreecommitdiff
path: root/emacs/inits/14-movement.el
blob: b44778e4ba2822b4be0d1487697670a3d3c66bd0 (plain)
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
;; Time-stamp: <2024-02-29 11h24 CET (f62464ac)>

;; -------------------------------------------------------------------
;; Repeated key presses for region

(use-package expand-region
  :ensure t
  :bind (("M-r" . er/expand-region))
  :config
  (setq expand-region-fast-keys-enabled t
        expand-region-contract-fast-key "c"
        expand-region-reset-fast-key "e"
        expand-region-autocopy-register "i"))

;; -------------------------------------------------------------------
;; Window switching

(use-package ace-window
  :ensure t
  :bind (("C-," . ace-window)
         ("C-x o" . ace-window))
  :config
  (setq aw-keys '(?a ?r ?s ?t ?c ?e ?n ?i)))

;; -------------------------------------------------------------------
;; Character jumping

(use-package avy
  :ensure t
  :demand
  :bind (("C->" . avy-goto-char-timer)
         ("C-." . avy-goto-char-in-line)
         ("M-g s" . avy-goto-word-or-subword-1)
         ("M-g w" . avy-goto-word-1)
         ("M-g a" . avy-goto-word-0)
         ("M-g C-g" . avy-goto-line))
  :config
  (setq avy-keys '(?a ?r ?s ?t ?g ?k ?n ?e ?i ?o ?q ?w ?f ?p)
        avy-dispatch-alist '((?w . avy-action-kill-move)
                             (?W . avy-action-kill-stay)
                             (?j . avy-action-teleport)
                             (?m . avy-action-mark)
                             (?c . avy-action-copy)
                             (?y . avy-action-yank)
                             (?i . avy-action-ispell)
                             (?z . avy-action-zap-to-char))))

;; -------------------------------------------------------------------
;; General stuff

;; (global-set-key (kbd "C-b") 'recenter-top-bottom)
;; (global-set-key (kbd "M-b") 'downcase-word)
;; (global-set-key (kbd "C-l") 'backward-char)
;; (global-set-key (kbd "M-l") 'backward-word)

(global-set-key (kbd "C-M-e") 'end-of-buffer)
(global-set-key (kbd "C-M-a") 'beginning-of-buffer)

(global-set-key (kbd "M-z") 'zap-up-to-char)

;; Fast movement
(global-set-key (kbd "C-S-n")
                (lambda () (interactive) (ignore-errors (forward-line 5))))

(global-set-key (kbd "C-S-p")
                (lambda () (interactive) (ignore-errors (forward-line -5))))

(global-set-key (kbd "C-S-f")
                (lambda () (interactive) (ignore-errors (forward-char 5))))

(global-set-key (kbd "C-S-b")
                (lambda () (interactive) (ignore-errors (backward-char 5))))

;; Hardcore mode
(defconst hardcore-nav-mode t)
(when hardcore-nav-mode
  (global-set-key (kbd "<XF86Back>") nil)
  (global-set-key (kbd "<XF86Forward>") nil)
  (global-set-key (kbd "<right>") nil)
  (global-set-key (kbd "<left>") nil)
  (global-set-key (kbd "<up>") nil)
  (global-set-key (kbd "<down>") nil)
  (global-set-key (kbd "S-<right>") nil)
  (global-set-key (kbd "S-<left>") nil)
  (global-set-key (kbd "S-<up>") nil)
  (global-set-key (kbd "C-<down>") nil)
  (global-set-key (kbd "C-<right>") nil)
  (global-set-key (kbd "C-<left>") nil)
  (global-set-key (kbd "C-<up>") nil)
  (global-set-key (kbd "C-<down>") nil)
  (global-set-key (kbd "<Home>") nil)
  (global-set-key (kbd "<End>") nil))