summaryrefslogtreecommitdiff
path: root/emacs/inits/14-movement.el
blob: c3a9409736f538c6b565c0f0a527a44667741ecd (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
93
94
95
96
97
98
99
100
101
102
103
;; Time-stamp: <2021-01-09 01:19:05 (tslil@bison)>

;; -------------------------------------------------------------------
;; 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 switch-window :ensure t
	:bind (("C-x o" . switch-window)
	 ("C-x C-o" . other-frame)
	 ("C-c o" . switch-window)
	 ("C-c n" . switch-window-then-maximize)
	 :map switch-window-extra-map
	 ("u" . switch-window-mvborder-up)
	 ("e" . switch-window-mvborder-down)
	 ("n" . switch-window-mvborder-left)
	 ("o" . switch-window-mvborder-right)
	 ("i" . nil)
	 ("j" . nil)
	 ("k" . nil)
	 ("l" . nil))
	:config
	(setq switch-window-input-style 'minibuffer
	switch-window-shortcut-style 'qwerty
	switch-window-multiple-frames nil
	switch-window-qwerty-shortcuts
	'("a" "r" "s" "t" "n" "e" "i" "o")))

;; -------------------------------------------------------------------
;; 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 M-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-M-e") 'end-of-buffer)
(global-set-key (kbd "C-M-a") 'beginning-of-buffer)

(global-set-key (kbd "M-h") 'backward-kill-word)

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

;; Fast movement
(global-set-key (kbd "M-n") 'scroll-up-command)
(global-set-key (kbd "M-p") 'scroll-down-command)

(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))