setup-keybindings.el 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. ;;; setup-keybindings.el --- Global keybindings.
  2. ;;
  3. ;;; Commentary:
  4. ;; List of global keybindings by major-mode.
  5. (require 'region-bindings-mode)
  6. ;;; Code:
  7. ;; Some bindings in active regions
  8. (region-bindings-mode-enable)
  9. ;; ---------
  10. ;; Generic keybindings
  11. ;; ---------
  12. ;; Basic
  13. (global-set-key (kbd "C-x t") 'toggle-truncate-lines)
  14. (global-set-key (kbd "C-c c p") 'copy-current-file-path)
  15. (global-set-key (kbd "C-c c e") 'copy-to-end-of-line)
  16. (global-set-key (kbd "C-c c w") 'copy-whole-lines)
  17. (global-set-key (kbd "<C-S-SPC>") 'cua-rectangle-mark-mode)
  18. (global-set-key (kbd "C-c y") 'browse-kill-ring)
  19. (global-set-key (kbd "M--") 'hippie-expand)
  20. (global-set-key (kbd "M-s--") 'distopico:hippie-expand-no-case-fold)
  21. (global-set-key (kbd "M-s-_") 'distopico:hippie-expand-lines)
  22. ;; Command with default hard keys such ^
  23. (global-set-key (kbd "C-S-d") 'delete-indentation)
  24. (global-set-key (kbd "M-s-.") 'dabbrev-expand)
  25. ;; File manager
  26. (global-set-key [f7] 'dired-jump-other-window)
  27. (global-set-key [f8] 'distopico:neotree-toggle)
  28. (global-set-key (kbd "M-<f8>") 'neotree-refresh)
  29. ;; Navigation
  30. (global-set-key (kbd "M-s-n") 'distopico:next-link)
  31. (global-set-key (kbd "M-s-p") 'distopico:previous-link)
  32. (global-set-key (kbd "M-s-<return>") 'distopico:show-link-url)
  33. ;; Buffer
  34. (global-set-key (kbd "C-x C-b") 'ibuffer)
  35. (global-set-key (kbd "C-x k") 'kill-this-buffer)
  36. (global-set-key (kbd "C-c k") 'kill-this-buffer-and-pane)
  37. (global-set-key (kbd "C-q") 'bury-buffer)
  38. (global-set-key (kbd "C-c C-k") 'kill-buffer)
  39. (global-set-key (kbd "s-b") 'bury-buffer)
  40. (global-set-key (kbd "<C-tab>") 'switch-to-previous-buffer)
  41. (global-set-key [C-M-next] 'next-buffer)
  42. (global-set-key [C-M-prior] 'previous-buffer)
  43. (global-set-key (kbd "C-c b b") 'ibuffer-other-window)
  44. (global-set-key (kbd "C-c b m") 'switch-to-minibuffer)
  45. (global-set-key (kbd "C-c b r") 'rename-buffer)
  46. (global-set-key (kbd "C-c b f") 'distopico:rename-current-buffer-file)
  47. (global-set-key (kbd "C-c b k") 'distopico:delete-current-buffer-file)
  48. ;; Revert without any fuss
  49. (global-set-key (kbd "C-c b c") (lambda () (revert-buffer t)))
  50. ;; Window
  51. (global-set-key (kbd "C-c w t") 'distopico:toggle-window-split)
  52. (global-set-key (kbd "C-c w r") 'distopico:rotate-windows)
  53. (global-set-key (kbd "C-c w s") 'windresize)
  54. (global-set-key (kbd "C-c w z") 'zoom-window-zoom)
  55. (global-set-key (kbd "C-c w n") 'zoom-window-next)
  56. (global-set-key (kbd "C-x 9") 'delete-windows-on)
  57. (global-set-key (kbd "M-0") 'ace-delete-window)
  58. (global-set-key (kbd "M-1") 'ace-delete-other-windows)
  59. (global-set-key (kbd "M-2") 'ace-window)
  60. (global-set-key (kbd "M-3") 'window-toggle-split-direction) ; toggle window position
  61. (global-set-key (kbd "M-4") 'windresize)
  62. ;; Reposition window
  63. (global-set-key (kbd "<M-s-home>") 'buf-move-up)
  64. (global-set-key (kbd "<M-s-end>") 'buf-move-down)
  65. (global-set-key (kbd "<M-s-next>") 'buf-move-left)
  66. (global-set-key (kbd "<M-s-prior>") 'buf-move-right)
  67. ;; Move bewteen windows
  68. ;; (global-set-key (kbd "C-x M-<left>") (ignore-error-wrapper 'windmove-left))
  69. ;; (global-set-key (kbd "C-x M-<right>") (ignore-error-wrapper 'windmove-right))
  70. ;; (global-set-key (kbd "C-x M-<up>") (ignore-error-wrapper 'windmove-up))
  71. ;; (global-set-key (kbd "C-x M-<down>") (ignore-error-wrapper 'windmove-down))
  72. ;; (global-set-key (kbd "C-c w <left>") (ignore-error-wrapper 'windmove-left))
  73. ;; (global-set-key (kbd "C-c w <right>") (ignore-error-wrapper 'windmove-right))
  74. ;; (global-set-key (kbd "C-c w <up>") (ignore-error-wrapper 'windmove-up))
  75. ;; (global-set-key (kbd "C-c w <down>") (ignore-error-wrapper 'windmove-down))
  76. ;; commenting/uncommenting
  77. ;; (global-set-key (kbd "M-;") 'comment-or-uncomment-current-line)
  78. (global-set-key (kbd "M-;") 'comment-dwim-line)
  79. ;; Tabbar
  80. (global-set-key (kbd "C-x <right>") 'tabbar-forward-tab)
  81. (global-set-key (kbd "C-x <left>") 'tabbar-backward-tab)
  82. (global-set-key (kbd "C-x <up>") 'tabbar-forward-group)
  83. (global-set-key (kbd "C-x <down>") 'tabbar-backward-group)
  84. ;; Zooming
  85. (global-set-key (kbd "<M-mouse-5>") 'text-scale-increase)
  86. (global-set-key (kbd "<M-mouse-4>") 'text-scale-decrease)
  87. (global-set-key (kbd "<C-M-mouse-1>") 'text-scale-adjust)
  88. (global-set-key (kbd "<C-M-mouse-3>") (lambda () (text-scale-decrease 0)))
  89. ;; PopWin
  90. (global-set-key (kbd "C-<escape>") 'popwin:close-popup-window)
  91. (global-set-key (kbd "s-<escape>") 'popwin:popup-last-buffer)
  92. ;; Query replace to anzu-replace
  93. (global-set-key [remap query-replace-regexp] 'anzu-query-replace-regexp)
  94. (global-set-key [remap query-replace] 'anzu-query-replace)
  95. (global-set-key (kbd "C-%") 'anzu-query-replace-at-cursor)
  96. ;; Isearch
  97. (define-key isearch-mode-map (kbd "C-o") 'isearch-occur)
  98. (define-key isearch-mode-map [next] 'isearch-repeat-forward)
  99. (define-key isearch-mode-map [prior] 'isearch-repeat-backward)
  100. ;; Toogle whitespace
  101. (global-set-key (kbd "C-x w") 'whitespace-mode)
  102. ;; Misc
  103. (global-set-key (kbd "C-c _") 'goto-last-change)
  104. (global-set-key (kbd "C-c u") 'distopico:pg-uline)
  105. ;; Terminal/Shell
  106. (global-set-key (kbd "C-c t a") 'popwin-term:ansi-term)
  107. (global-set-key (kbd "C-c t m") 'popwin-term:multi-term)
  108. (global-set-key (kbd "C-c t t") 'popwin-term:term)
  109. (global-set-key (kbd "C-c t s") 'shell)
  110. (global-set-key (kbd "C-c t e") 'eshell)
  111. ;; Toogle Bars
  112. (global-set-key (kbd "C-<f1>") 'tool-bar-mode)
  113. (global-set-key (kbd "C-<f2>") 'menu-bar-mode)
  114. ;; Perform general cleanup
  115. (global-set-key (kbd "C-c n") 'cleanup-buffer)
  116. (global-set-key (kbd "C-c C-n") 'distopico:cleanup-buffer)
  117. (global-set-key (kbd "C-c C-w") 'delete-trailing-whitespace)
  118. ;; Ido
  119. (global-set-key (kbd "C-c r") 'ido-recentf-open)
  120. (global-set-key (kbd "C-c i r") 'ido-recentf-open)
  121. (global-set-key (kbd "C-c i s") 'ido-goto-symbol)
  122. (global-set-key (kbd "C-c i b") 'ido-switch-buffer)
  123. (global-set-key (kbd "C-c i w") 'ido-select-window)
  124. (global-set-key (kbd "C-c i o") 'ido-occur)
  125. (global-set-key (kbd "C-x B") 'ido-for-this-mode)
  126. (global-set-key (kbd "C-x O") 'ido-select-window)
  127. ;; Imenu
  128. (global-set-key (kbd "C-x c") 'imenu)
  129. (global-set-key [S-mouse-3] 'imenu)
  130. ;; Avy
  131. (global-set-key (kbd "C-: c") 'avy-goto-char)
  132. (global-set-key (kbd "C-: v") 'avy-goto-char-2)
  133. (global-set-key (kbd "C-: l") 'avy-goto-line)
  134. (global-set-key (kbd "C-: w") 'avy-goto-word-1)
  135. (global-set-key (kbd "C-: e") 'avy-goto-word-0)
  136. (global-set-key (kbd "M-z") 'avy-zap-to-char-dwim)
  137. (global-set-key (kbd "M-Z") 'avy-zap-up-to-char-dwim)
  138. ;; Move-dup
  139. ;; default M-<up> md-move-lines-up / M-<down> md-move-lines-down
  140. (global-set-key (kbd "M-s-<down>") 'move-dup-duplicate-down)
  141. (global-set-key (kbd "M-s-<up>") 'move-dup-duplicate-up)
  142. ;; Actions
  143. (global-set-key (kbd "C-x <next>") 'select-current-line)
  144. (global-set-key (kbd "C-c e <right>") 'select-current-line)
  145. ;; HideShow
  146. (global-set-key (kbd "C-x |") 'toggle-hiding)
  147. ;; Magit
  148. (global-set-key (kbd "C-x g") 'magit-status)
  149. (global-set-key (kbd "C-x G") 'magit-status-quick)
  150. ;; Mail
  151. (global-set-key (kbd "C-x M-m") 'distopico:mu4e-open)
  152. ;; News
  153. (global-set-key (kbd "C-x M-n") 'distopico:elfeed-open)
  154. ;; Pomodoro
  155. (global-set-key (kbd "C-x M-p") 'pomodoro-action)
  156. ;; Erc
  157. (global-set-key (kbd "C-x M-e") 'distopico:erc-start-ask-or-switch)
  158. ;; GnuSocial
  159. (global-set-key (kbd "C-x M-g") 'distopico:gnusocial-open)
  160. (define-key global-map (kbd "C-c g")
  161. (let ((map (make-sparse-keymap)))
  162. (define-key map "s" 'gnusocial-update-status-interactive)
  163. (define-key map "a" 'gnu-social-direct-message-interactive)
  164. (define-key map "o" 'distopico:gnusocial-open)
  165. map))
  166. ;; Jabebr
  167. (global-set-key (kbd "C-x M-j") 'distopico:jabber-roster-or-switch)
  168. (define-key global-map (kbd "C-c j")
  169. (let ((map (make-sparse-keymap)))
  170. (define-key map "c" 'jabber-connect-all)
  171. (define-key map "d" 'jabber-disconnect)
  172. (define-key map "r" 'distopico:jabber-display-roster)
  173. (define-key map "j" 'jabber-chat-with)
  174. (define-key map "l" 'jabber-activity-switch-to)
  175. (define-key map "a" 'jabber-send-away-presence)
  176. (define-key map "o" 'jabber-send-default-presence)
  177. (define-key map "x" 'jabber-send-xa-presence)
  178. (define-key map "p" 'jabber-send-presence)
  179. map))
  180. ;; Org
  181. (define-key global-map (kbd "C-c o")
  182. (let ((map (make-sparse-keymap)))
  183. (define-key map "f" 'org-switchb)
  184. (define-key map "a" 'distopico:org-show-agenda)
  185. (define-key map "A" 'org-agenda-list)
  186. (define-key map "v" 'org-agenda)
  187. (define-key map "c" 'org-capture)
  188. (define-key map "t" 'org-clock-goto)
  189. (define-key map "P" 'pomodoro-org)
  190. (define-key map "u" 'distopico:org-run-appt)
  191. (define-key map "p" 'org-projectile-project-todo-completing-read)
  192. (define-key map "n" 'org-annotate-file)
  193. (define-key map "l" 'org-store-link)
  194. (define-key map "L" 'org-insert-link-global)
  195. (define-key map "o" 'org-open-at-point-global)
  196. map))
  197. (provide 'setup-keybindings)
  198. ;;; setup-keybindings.el ends here