shortcuts.el 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. ;;; package --- Conf shortcuts
  2. ;;;
  3. ;;; Commentary:
  4. ;;; My list of keybindings
  5. ;;;
  6. ;;; Code:
  7. (global-set-key (kbd "C-c fd") 'find-dired)
  8. (global-set-key (kbd "C-c d") 'diff-buffer-with-file)
  9. (global-set-key (kbd "C-c R") 'revert-buffer)
  10. (global-set-key (kbd "s-i") 'dired-omit-mode)
  11. (global-set-key (kbd "C-<right>") 'next-buffer)
  12. (global-set-key (kbd "C-<left>") 'previous-buffer)
  13. (global-set-key (kbd "<backtab>") 'helm-buffers-list)
  14. (global-set-key (kbd "C-<tab>") 'ibuffer-other-window)
  15. (global-set-key (kbd "C-c b") 'list-buffers)
  16. ;;(global-set-key (kbd "M-t") 'dirtree-in-buffer)
  17. ;;(global-set-key (kbd "M-d") 'dirtree)
  18. (global-set-key [f9] 'nav-toggle)
  19. ;; Life-hack keybindings
  20. (global-set-key (kbd "C-c lc") 'calendar)
  21. (global-set-key (kbd "C-c lp") 'plan)
  22. ;; Horizontal scroll
  23. ;;(global-set-key (kbd "<mouse-6>") 'scroll-right)
  24. ;;(global-set-key (kbd "<mouse-7>") 'scroll-left)
  25. ;; Errors
  26. (global-set-key (kbd "s-<f2>") 'flycheck-list-errors)
  27. ;; Basics
  28. (global-set-key (kbd "C-s") 'save-buffer)
  29. (global-set-key (kbd "M-v") 'browse-kill-ring)
  30. (global-set-key (kbd "C-w") 'kill-ring-save)
  31. (global-set-key (kbd "M-w") 'kill-region)
  32. (global-set-key (kbd "C-f") 'isearch-forward)
  33. (global-set-key (kbd "C-s-r") 'isearch-backward)
  34. (global-set-key (kbd "C-S-x") 'clipboard-kill-region) ; cut.
  35. (global-set-key (kbd "C-c c") 'clipboard-kill-ring-save) ; copy.
  36. (global-set-key (kbd "C-v") 'clipboard-yank) ; paste.
  37. (global-set-key [mouse-2] 'clipboard-kill-ring-save)
  38. (defalias 'redo 'undo-tree-redo)
  39. (global-set-key (kbd "C-z") 'undo)
  40. (global-set-key (kbd "C-S-z") 'redo)
  41. (global-set-key [f8] 'toggle-truncate-lines)
  42. (global-set-key (kbd "C-c l") 'goto-line)
  43. ;;(global-set-key (kbd "RET") 'newline-and-indent)
  44. (global-set-key (kbd "C-q") 'kill-this-buffer)
  45. ;; window positioning
  46. (global-set-key (kbd "s-?") 'enlarge-window)
  47. (global-set-key (kbd "s-=") 'shrink-window)
  48. (global-set-key (kbd "s-+") 'enlarge-window-horizontally)
  49. (global-set-key (kbd "s--") 'shrink-window-horizontally)
  50. (global-set-key (kbd "<C-s-up>") 'buf-move-up)
  51. (global-set-key (kbd "<C-s-down>") 'buf-move-down)
  52. (global-set-key (kbd "<C-s-left>") 'buf-move-left)
  53. (global-set-key (kbd "<C-s-right>") 'buf-move-right)
  54. ;; window configuration
  55. (global-set-key (kbd "C-x j") 'jump-to-register)
  56. (global-set-key (kbd "C-c s") 'window-configuration-to-register)
  57. (global-set-key (kbd "C-c x") 'execute-extended-command)
  58. (global-set-key [S-prior] 'beginning-of-buffer)
  59. (global-set-key [S-next] 'end-of-buffer)
  60. ;; easy keys to split window. Key based on ErgoEmacs keybinding
  61. (global-set-key (kbd "M-0") 'delete-window) ; close current pane
  62. (global-set-key (kbd "M-1") 'delete-other-windows) ; expand current pane
  63. (global-set-key (kbd "M-2") 'split-window-horizontally) ; split pane left/rigth
  64. (global-set-key (kbd "M-3") 'split-window-vertically) ; split pane top/bottom
  65. (global-set-key (kbd "M-4") 'other-window) ; cursor to other pane
  66. (global-set-key (kbd "M-5") 'toggle-window-split) ; toggle window position
  67. (global-set-key (kbd "M-6") 'window-toggle-split-direction) ; toggle window position
  68. ;; Django
  69. (global-set-key (kbd "C-x d") 'python-django-open-project)
  70. ;; Toogle Bars
  71. (global-set-key (kbd "C-<f1>") 'tool-bar-mode)
  72. (global-set-key (kbd "C-<f2>") 'menu-bar-mode)
  73. ;; Toogle whitespace
  74. (global-set-key (kbd "C-<f3>") 'whitespace-mode)
  75. ;; indentation
  76. (global-set-key (kbd "C-c C->") 'increase-left-margin)
  77. (global-set-key (kbd "C-c C-<") 'decrease-left-margin)
  78. ;; misc
  79. (global-set-key (kbd "C-`") 'rename-buffer)
  80. ;; zooming
  81. (global-set-key (kbd "<M-mouse-5>") 'text-scale-increase)
  82. (global-set-key (kbd "<M-mouse-4>") 'text-scale-decrease)
  83. ;; terminal
  84. (global-set-key
  85. (kbd "C-c t")
  86. (lambda () (interactive) (ansi-term "/bin/bash")))
  87. (global-set-key (kbd "C-x t") (lambda () (interactive) (popwin-term:term))
  88. )
  89. ;; Open shell with C-z
  90. (global-set-key (kbd "M-t") 'shell)
  91. ;; Browse URLs with C-x /
  92. (global-set-key (kbd "C-x /") 'browse-url)
  93. ;; commenting/uncommenting
  94. (defun my/comment-or-uncomment-current-line ()
  95. (interactive)
  96. (comment-or-uncomment-region (line-beginning-position) (line-end-position)))
  97. (global-set-key (kbd "C-x C-;") 'my/comment-or-uncomment-current-line)
  98. ;; Error jumping
  99. (global-set-key (kbd "C-x <C-down>") 'next-error)
  100. (global-set-key (kbd "C-x <C-up>") 'previous-error)
  101. ;; sort lines
  102. (global-set-key (kbd "C-c C-s") 'sort-lines)
  103. ;; window opacity utilities
  104. ;; C-+ will increase opacity (== decrease transparency)
  105. (global-set-key (kbd "C-<kp-add>")
  106. '(lambda()
  107. (interactive)
  108. (sa-opacity-modify)))
  109. ;; C-- will decrease opaccity (== increase transparency
  110. (global-set-key (kbd "C-<kp-subtract>")
  111. '(lambda()
  112. (interactive)
  113. (sa-opacity-modify t)))
  114. ;; C-0 will returns the state to normal
  115. (global-set-key (kbd "C-=")
  116. '(lambda()
  117. (interactive)
  118. (modify-frame-parameters nil `((alpha . 100)))))
  119. ;; toggle two most recent buffers
  120. (fset 'quick-switch-buffer [?\C-x ?b return])
  121. (global-set-key (kbd "s-q") 'quick-switch-buffer)
  122. (global-set-key (kbd "s-y") 'bury-buffer)
  123. ;; Revert without any fuss
  124. ;;(global-set-key (kbd "M-<escape>") (λ (revert-buffer t t)))
  125. ;; Copy file path to kill ring
  126. (global-set-key (kbd "C-x M-w") 'copy-current-file-path)
  127. ;; PopWin
  128. (global-set-key (kbd "C-<escape>") 'popwin:close-popup-window)
  129. (global-set-key (kbd "s-4") 'popwin:popup-buffer)
  130. (global-set-key (kbd "s-3") 'popwin:popup-last-buffer)
  131. (global-set-key (kbd "s-2") 'popwin:display-buffer)
  132. (global-set-key (kbd "s-1") 'popwin:one-window)
  133. ;; Skewer
  134. (global-set-key (kbd "M-<f12>") 'run-skewer)
  135. (global-set-key (kbd "M-<f11>") 'skewer-start)
  136. (global-set-key (kbd "M-<f10>") 'skewer-demo)
  137. ;; Projects
  138. (global-set-key (kbd "C-<f11>") 'dired-jump-other-window)
  139. (global-set-key (kbd "C-<f10>") 'direx-project:jump-to-project-root-other-window)
  140. (global-set-key (kbd "C-<f9>") 'direx:jump-to-directory-other-window)
  141. (global-set-key (kbd "C-<f8>") 'project-explorer-open)
  142. (global-set-key (kbd "C-<f7>") 'direx:jump-to-directory)
  143. ;; Smart-forward
  144. (global-set-key (kbd "M-<up>") 'smart-up)
  145. (global-set-key (kbd "M-<down>") 'smart-down)
  146. (global-set-key (kbd "M-<left>") 'smart-backward)
  147. (global-set-key (kbd "M-<right>") 'smart-forward)
  148. ;; Perform general cleanup.
  149. (global-set-key (kbd "C-c n") 'cleanup-buffer)
  150. (global-set-key (kbd "C-c C-n") 'cleanup-buffer)
  151. (global-set-key (kbd "C-c C-<return>") 'delete-blank-lines)
  152. ;; YaSnippet
  153. (define-key yas-minor-mode-map (kbd "<tab>") nil)
  154. (define-key yas-minor-mode-map (kbd "TAB") nil)
  155. (define-key yas-minor-mode-map (kbd "M-q") 'yas-expand)
  156. ;; Smartparens
  157. (global-set-key (kbd "C-<f6>") 'sp-select-next-thing)
  158. ;; Recent Files
  159. (global-set-key (kbd "C-x r <down>") 'ido-recentf-open)
  160. (global-set-key (kbd "C-c C-f") 'helm-for-files)
  161. (global-set-key (kbd "C-c r <down>") 'helm-recentf)
  162. ;; Highlight
  163. (global-set-key (kbd "C-c C-o") 'highlight-symbol-occur)
  164. (global-set-key (kbd "C-c M-<right>") 'highlight-symbol-next-in-defun)
  165. (global-set-key (kbd "C-c M-<left>") 'highlight-symbol-prev-in-defun)
  166. (global-set-key (kbd "s-<f3>") 'highlight-symbol-at-point)
  167. (global-set-key (kbd "s-<f4>") 'highlight-symbol-prev)
  168. (global-set-key (kbd "s-<f5>") 'highlight-symbol-next)
  169. (global-set-key (kbd "s-<f6>") 'highlight-symbol-query-replace)
  170. (global-set-key (kbd "s-<f7>") 'unhighlight-regexp)
  171. ;; Buffer
  172. (global-set-key (kbd "C-c o") 'switch-to-minibuffer)
  173. (global-set-key (kbd "<f5>") 'select-active-minibuffe)
  174. ;; Go to char
  175. (global-set-key (kbd "C-c f") 'iy-go-to-char)
  176. (global-set-key (kbd "C-c F") 'iy-go-to-char-backward)
  177. (global-set-key (kbd "C-c ;") 'iy-go-to-or-up-to-continue)
  178. (global-set-key (kbd "C-c ,") 'iy-go-to-or-up-to-continue-backward)
  179. ;; Magit
  180. (global-set-key (kbd "C-x g") 'magit-status)
  181. (autoload 'magit-status "magit")
  182. ;; Helm
  183. (global-set-key (kbd "C-c h") 'helm-mini)
  184. (global-set-key (kbd "M-ñ") 'helm-semantic-or-imenu)
  185. (global-set-key (kbd "C-x y") 'helm-show-kill-ring)
  186. (global-set-key (kbd "M-x") 'helm-M-x)
  187. (global-set-key (kbd "C-c C-e") 'emacs-d-find-file)
  188. ;; Org
  189. (global-set-key "\C-c \C-l" 'org-store-link)
  190. (global-set-key "\C-ca" 'org-agenda)
  191. (global-set-key "\C-c \C-b" 'org-iswitchb)
  192. (provide 'shortcuts)
  193. ;;; shortcuts.el ends here