Emacs-fu: some handy key bindings
emacs-fu.blogspot.com
emacs-fu.blogspot.com
^X-2: Split window horizontally
^X-3: Split window vertically
^X-0: Combine window with sibling
^X-1: Undo all splits
From my .emacs file: ;;; Key bindings
(global-set-key "\C-xg" 'goto-line)
(global-set-key "\C-xl" 'what-line)
(global-set-key [f1] 'goto-line)
(global-set-key [f2] 'switch-to-buffer)
(global-set-key [f3] 'shell)
(global-set-key [f4] 'query-replace)
(global-set-key [f5] 'compare-windows)
(global-set-key [f6] 'set-left-margin)
(global-set-key [f7] 'find-file)
(global-set-key [S-f7] 'revert-buffer)
(global-set-key [f8] 'save-buffer)
(global-set-key [f9] 'auto-fill-mode)
(global-set-key [f10] 'call-last-kbd-macro)
(global-set-key [S-f10] 'apply-macro-to-region-lines)
(global-set-key [f11] 'sort-lines)
(global-set-key [f12] 'undo)
(global-set-key [home] 'beginning-of-line)
(global-set-key [end] 'end-of-line)
;;; no insert key on mac keyboard
(global-set-key [insert] 'other-window)
(global-set-ke y [help] 'other-window)
(global-set-key [S-help] 'yank)
(global-set-key [C-home] 'beginning-of-buffer)
(global-set-key [C-end] 'end-of-buffer)
(global-set-key [S-next] 'scroll-other-window)
(global-set-key [S-prior] 'scroll-other-window-down)
Not key bindings, but very nice to have in .emacs: ;;; this highlights the marked region
(transient-mark-mode t)
;; don't automatically add new lines when scrolling down at
;; the bottom
;;of a buffer.
(setq next-line-add-newlines nil)
;;; Don't truncate lines when windows are split vertically
(setq-default truncate-partial-width-windows nil)Here's some of mine (full config @ http://github.com/cycojesus/emacs )
(global-set-key (kbd "C-z") 'undo)
(global-set-key [delete] 'delete-char)
(global-set-key [kp-delete] 'delete-char)
(global-set-key (kbd "C-c b") 'browse-url)
(global-set-key (kbd "C-c c") 'calendar)
(global-set-key (kbd "C-c h") 'calc) ;; 'h' for 'h'P-48
(global-set-key (kbd "C-c l") 'linum-mode)
(global-set-key (kbd "C-c w") 'whitespace-mode)
(global-set-key [(control mouse-4)] (lambda () (interactive)
(text-scale-increase 1)))
(global-set-key [(control mouse-5)] (lambda () (interactive)
(text-scale-decrease 1)))
(define-key global-map (kbd "RET") 'newline-and-indent)
(global-set-key (kbd "C-;") 'shrink-window)
(global-set-key (kbd "C-.") 'enlarge-window)
(global-set-key (kbd "M-/") 'hippie-expand)
;; scrollwheel on the modeline to navigate buffers
(global-set-key [mode-line mouse-4] 'next-buffer)
(global-set-key [mode-line mouse-5] 'previous-buffer)Sometimes I wish for a keybinding revolution...
Yes, I know that keys can be remapped, and have done so on my machines, but sensible defaults are still a good thing to have, if only to welcome new users.
I find key combinations like these clunky:
C-x C-e
C-M-x
First, find the name of the function you want to rebind. Press C-h k (describe-key), and then the normal shortcut for the command you want to rebind. It should open a help buffer beginning with e.g. "C-x C-e runs the command something-hyphenated". That's your command name. (You can get a list of all commands in clojure's mode by pressing C-h m, which might be quicker if you're redefining several.)
Then, set up a mode-specific hook (something that runs when you edit a buffer in that mode). Add this to your Emacs config:
(add-hook 'clojure-mode-hook 'my-clojure-mode-hook)
(or whatever the clojure mode is called, I haven't used clojure). Finally, define your mode hook and add custom local keybindings with local-set-key. It should look like this: (defun my-clojure-mode-hook ()
(local-set-key (kbd "better-shortcut") 'name-of-command)
(local-set-key (kbd "better-shortcut-2") 'name-of-second-command))
Where (kbd "better-shortcut") is in the usual Emacs keyboard shortcut notation, like (kbd "C-M-e").* To figure out what this is for a key, you can press C-h k again, followed by your shortcut. It will say "X is unbound", "X is assemble-delicious-sandwich", or whatever. The X part is what Emacs calls that key combination.* You don't strictly need the (kbd "string") form, but it's probably the simplest form to use - you can press C-x C-e after the (kbd _) form to verify that it recognizes the key description.
Anything else you want to run when you start editing clojure code can go in the mode hook, too. Let me know if you have any questions. While I haven't done much with clojure, I know customizing Emacs pretty well, and adding keybindings like this works for any mode. You just need to know what the mode is called.
C-X C-c; vim
Though personally I've never found it that useful.