Starter Kit Bindings

This is part of the Emacs Starter Kit.

Starter Kit Bindings

Key Bindings.

You know, like Readline.

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

Align your code in a pretty way.

(global-set-key (kbd "C-x \\") 'align-regexp)

Completion that uses many different methods to find options.

(global-set-key (kbd "M-/") 'hippie-expand)

Perform general cleanup.

(global-set-key (kbd "C-c n") 'cleanup-buffer)

Turn on the menu bar for exploring new modes

(global-set-key [f1] 'menu-bar-mode)

Font size

(define-key global-map (kbd "C-+") 'text-scale-increase)
(define-key global-map (kbd "C--") 'text-scale-decrease)

Use regex searches by default.

(global-set-key (kbd "C-s") 'isearch-forward-regexp)
(global-set-key (kbd "\C-r") 'isearch-backward-regexp)
(global-set-key (kbd "C-M-s") 'isearch-forward)
(global-set-key (kbd "C-M-r") 'isearch-backward)

Jump to a definition in the current file. (This is awesome.)

(global-set-key (kbd "C-x C-i") 'ido-imenu)

File finding

(global-set-key (kbd "C-x M-f") 'ido-find-file-other-window)
(global-set-key (kbd "C-x C-M-f") 'find-file-in-project)
(global-set-key (kbd "C-x f") 'recentf-ido-find-file)
(global-set-key (kbd "C-x C-p") 'find-file-at-point)
(global-set-key (kbd "C-c y") 'bury-buffer)
(global-set-key (kbd "C-c r") 'revert-buffer)
(global-set-key (kbd "M-`") 'file-cache-minibuffer-complete)
(global-set-key (kbd "C-x C-b") 'ibuffer)

Window switching. (C-x o goes to the next window)

(windmove-default-keybindings) ;; Shift+direction
(global-set-key (kbd "C-x O") (lambda () (interactive) (other-window -1))) ;; back one
(global-set-key (kbd "C-x C-o") (lambda () (interactive) (other-window 2))) ;; forward two

Indentation help

(global-set-key (kbd "C-x ^") 'join-line)

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)

Fetch the contents at a URL, display it raw.

(global-set-key (kbd "C-x h") 'view-url)

Help should search more than just commands

(global-set-key (kbd "C-h a") 'apropos)

Should be able to eval-and-replace anywhere.

(global-set-key (kbd "C-c e") 'eval-and-replace)


(global-set-key (kbd "C-c j") (lambda () (interactive) (switch-or-start 'jabber-connect "*-jabber-*")))
(global-set-key (kbd "C-c g") (lambda () (interactive) (switch-or-start 'gnus "*Group*")))
(global-set-key (kbd "C-c i") (lambda () (interactive) (switch-or-start (lambda ()
                                                                     (rcirc-connect ""))
(global-set-key (kbd "C-c J") 'jabber-send-presence)
(global-set-key (kbd "C-c M-j") 'jabber-disconnect)
(global-set-key (kbd "C-x g") 'magit-status)

This is a little hacky since VC doesn't support git add internally

(eval-after-load 'vc
  (define-key vc-prefix-map "i" '(lambda () (interactive)
                                   (if (not (eq 'Git (vc-backend buffer-file-name)))
                                     (shell-command (format "git add %s" buffer-file-name))
                                     (message "Staged changes.")))))

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


(provide 'starter-kit-bindings)
;;; starter-kit-bindings.el ends here


Two global binding for Org-mode (see starter-kit-org)

The Org-mode agenda is good to have close at hand

(define-key global-map "\C-ca" 'org-agenda)

Org-mode supports links, this command allows you to store links globally for later insertion into an Org-mode buffer. See Handling-links in the Org-mode manual.

(define-key global-map "\C-cl" 'org-store-link)


It's to the point now where I almost can't use git without magit.



Rgrep is infinitely useful in multi-file projects.

(see @<elisp:(describe-function 'rgrep)>@)

(define-key global-map "\C-x\C-r" 'rgrep)