124 lines
3.9 KiB
EmacsLisp
124 lines
3.9 KiB
EmacsLisp
;;; prelude-global-keybindings.el --- Emacs Prelude: some useful keybindings.
|
|
;;
|
|
;; Copyright © 2011-2013 Bozhidar Batsov
|
|
;;
|
|
;; Author: Bozhidar Batsov <bozhidar@batsov.com>
|
|
;; URL: https://github.com/bbatsov/prelude
|
|
;; Version: 1.0.0
|
|
;; Keywords: convenience
|
|
|
|
;; This file is not part of GNU Emacs.
|
|
|
|
;;; Commentary:
|
|
|
|
;; Lots of useful keybindings.
|
|
|
|
;;; License:
|
|
|
|
;; This program is free software; you can redistribute it and/or
|
|
;; modify it under the terms of the GNU General Public License
|
|
;; as published by the Free Software Foundation; either version 3
|
|
;; of the License, or (at your option) any later version.
|
|
;;
|
|
;; This program is distributed in the hope that it will be useful,
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
;; GNU General Public License for more details.
|
|
;;
|
|
;; You should have received a copy of the GNU General Public License
|
|
;; along with GNU Emacs; see the file COPYING. If not, write to the
|
|
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
;; Boston, MA 02110-1301, USA.
|
|
|
|
;;; Code:
|
|
|
|
;; Align your code in a pretty way.
|
|
(global-set-key (kbd "C-x \\") 'align-regexp)
|
|
|
|
;; Font size
|
|
(global-set-key (kbd "C-+") 'text-scale-increase)
|
|
(global-set-key (kbd "C--") 'text-scale-decrease)
|
|
|
|
;; Window switching. (C-x o goes to the next window)
|
|
(global-set-key (kbd "C-x O") (lambda ()
|
|
(interactive)
|
|
(other-window -1))) ;; back one
|
|
|
|
;; Indentation help
|
|
(global-set-key (kbd "C-x ^") 'join-line)
|
|
|
|
;; Start proced in a similar manner to dired
|
|
(global-set-key (kbd "C-x p") 'proced)
|
|
|
|
;; Start eshell or switch to it if it's active.
|
|
(global-set-key (kbd "C-x m") 'eshell)
|
|
|
|
;; Start a new eshell even if one is active.
|
|
(global-set-key (kbd "C-x M") (lambda () (interactive) (eshell t)))
|
|
|
|
;; Start a regular shell if you prefer that.
|
|
(global-set-key (kbd "C-x M-m") 'shell)
|
|
|
|
;; If you want to be able to M-x without meta
|
|
(global-set-key (kbd "C-x C-m") 'execute-extended-command)
|
|
|
|
;; A complementary binding to the apropos-command (C-h a)
|
|
(define-key 'help-command "A" 'apropos)
|
|
|
|
(global-set-key (kbd "C-h C-f") 'find-function)
|
|
(global-set-key (kbd "C-h C-k") 'find-function-on-key)
|
|
(global-set-key (kbd "C-h C-v") 'find-variable)
|
|
(global-set-key (kbd "C-h C-l") 'find-library)
|
|
|
|
;; a complement to the zap-to-char command, that doesn't eat up the target character
|
|
(autoload 'zap-up-to-char "misc" "Kill up to, but not including ARGth occurrence of CHAR.")
|
|
(global-set-key (kbd "M-Z") 'zap-up-to-char)
|
|
|
|
;; kill lines backward
|
|
(global-set-key (kbd "C-<backspace>") (lambda ()
|
|
(interactive)
|
|
(kill-line 0)
|
|
(indent-according-to-mode)))
|
|
|
|
(global-set-key [remap kill-whole-line] 'prelude-kill-whole-line)
|
|
|
|
;; Activate occur easily inside isearch
|
|
(define-key isearch-mode-map (kbd "C-o")
|
|
(lambda () (interactive)
|
|
(let ((case-fold-search isearch-case-fold-search))
|
|
(occur (if isearch-regexp
|
|
isearch-string
|
|
(regexp-quote isearch-string))))))
|
|
|
|
;; use hippie-expand instead of dabbrev
|
|
(global-set-key (kbd "M-/") 'hippie-expand)
|
|
|
|
;; replace buffer-menu with ibuffer
|
|
(global-set-key (kbd "C-x C-b") 'ibuffer)
|
|
|
|
;; toggle menu-bar visibility
|
|
(global-set-key (kbd "<f12>") 'menu-bar-mode)
|
|
|
|
(global-set-key (kbd "C-x g") 'magit-status)
|
|
|
|
(global-set-key (kbd "C-=") 'er/expand-region)
|
|
|
|
;; make C-x C-x usable with transient-mark-mode
|
|
(define-key global-map
|
|
[remap exchange-point-and-mark]
|
|
'prelude-exchange-point-and-mark)
|
|
|
|
(global-set-key (kbd "C-c SPC") 'ace-jump-mode)
|
|
(global-set-key (kbd "C-x SPC") 'ace-jump-mode-pop-mark)
|
|
|
|
;; key chords
|
|
(require 'key-chord)
|
|
|
|
(key-chord-define-global "jj" 'ace-jump-mode)
|
|
(key-chord-define-global "JJ" 'prelude-switch-to-previous-buffer)
|
|
|
|
(key-chord-mode +1)
|
|
|
|
(provide 'prelude-global-keybindings)
|
|
|
|
;;; prelude-global-keybindings.el ends here
|