Emacs config utilizing prelude as a base
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

121 lines
3.9 KiB

14 years ago
14 years ago
14 years ago
14 years ago
5 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
  1. ;;; prelude-global-keybindings.el --- Emacs Prelude: some useful keybindings.
  2. ;;
  3. ;; Copyright © 2011-2021 Bozhidar Batsov
  4. ;;
  5. ;; Author: Bozhidar Batsov <bozhidar@batsov.com>
  6. ;; URL: https://github.com/bbatsov/prelude
  7. ;; This file is not part of GNU Emacs.
  8. ;;; Commentary:
  9. ;; Lots of useful keybindings.
  10. ;;; License:
  11. ;; This program is free software; you can redistribute it and/or
  12. ;; modify it under the terms of the GNU General Public License
  13. ;; as published by the Free Software Foundation; either version 3
  14. ;; of the License, or (at your option) any later version.
  15. ;;
  16. ;; This program is distributed in the hope that it will be useful,
  17. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. ;; GNU General Public License for more details.
  20. ;;
  21. ;; You should have received a copy of the GNU General Public License
  22. ;; along with GNU Emacs; see the file COPYING. If not, write to the
  23. ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  24. ;; Boston, MA 02110-1301, USA.
  25. ;;; Code:
  26. ;; Align your code in a pretty way.
  27. (global-set-key (kbd "C-x \\") 'align-regexp)
  28. ;; Font size
  29. (global-set-key (kbd "C-+") 'text-scale-increase)
  30. (global-set-key (kbd "C--") 'text-scale-decrease)
  31. ;; Window switching. (C-x o goes to the next window)
  32. (global-set-key (kbd "C-x O") (lambda ()
  33. (interactive)
  34. (other-window -1))) ;; back one
  35. ;; Indentation help
  36. (global-set-key (kbd "C-^") 'crux-top-join-line)
  37. ;; Start proced in a similar manner to dired
  38. (global-set-key (kbd "C-x p") 'proced)
  39. ;; Start eshell or switch to it if it's active.
  40. (global-set-key (kbd "C-x m") 'eshell)
  41. ;; Start a new eshell even if one is active.
  42. (global-set-key (kbd "C-x M") (lambda () (interactive) (eshell t)))
  43. ;; Start a regular shell if you prefer that.
  44. (global-set-key (kbd "C-x M-m") 'shell)
  45. ;; If you want to be able to M-x without meta
  46. (global-set-key (kbd "C-x C-m") 'smex)
  47. ;; A complementary binding to the apropos-command (C-h a)
  48. (define-key 'help-command "A" 'apropos)
  49. ;; A quick major mode help with discover-my-major
  50. (define-key 'help-command (kbd "C-m") 'discover-my-major)
  51. (define-key 'help-command (kbd "C-f") 'find-function)
  52. (define-key 'help-command (kbd "C-k") 'find-function-on-key)
  53. (define-key 'help-command (kbd "C-v") 'find-variable)
  54. (define-key 'help-command (kbd "C-l") 'find-library)
  55. (define-key 'help-command (kbd "C-i") 'info-display-manual)
  56. ;; replace zap-to-char functionality with the more powerful zop-to-char
  57. (global-set-key (kbd "M-z") 'zop-up-to-char)
  58. (global-set-key (kbd "M-Z") 'zop-to-char)
  59. ;; kill lines backward
  60. (global-set-key (kbd "C-<backspace>") 'crux-kill-line-backwards)
  61. (global-set-key [remap kill-whole-line] 'crux-kill-whole-line)
  62. ;; Activate occur easily inside isearch
  63. (define-key isearch-mode-map (kbd "C-o") 'isearch-occur)
  64. ;; use hippie-expand instead of dabbrev
  65. (global-set-key (kbd "M-/") 'hippie-expand)
  66. ;; replace buffer-menu with ibuffer
  67. (global-set-key (kbd "C-x C-b") 'ibuffer)
  68. ;; toggle menu-bar visibility
  69. (global-set-key (kbd "<f12>") 'menu-bar-mode)
  70. ;; Magit creates some global keybindings by default
  71. ;; but it's a nice to complement them with this one
  72. (global-set-key (kbd "C-c g") 'magit-file-dispatch)
  73. (global-set-key (kbd "C-=") 'er/expand-region)
  74. ;; recommended avy keybindings
  75. (global-set-key (kbd "C-:") 'avy-goto-char)
  76. (global-set-key (kbd "C-'") 'avy-goto-char-2)
  77. (global-set-key (kbd "M-g f") 'avy-goto-line)
  78. (global-set-key (kbd "M-g w") 'avy-goto-word-1)
  79. (global-set-key (kbd "M-g e") 'avy-goto-word-0)
  80. ;; additional avy keybindings
  81. (global-set-key (kbd "s-,") 'avy-goto-char)
  82. (global-set-key (kbd "s-.") 'avy-goto-word-or-subword-1)
  83. (global-set-key (kbd "C-c v") 'avy-goto-word-or-subword-1)
  84. ;; improved window navigation with ace-window
  85. (global-set-key (kbd "s-w") 'ace-window)
  86. (global-set-key [remap other-window] 'ace-window)
  87. (provide 'prelude-global-keybindings)
  88. ;;; prelude-global-keybindings.el ends here