Here are some practical emacs keybinding suggestions to enhance productivity.
(global-set-key (kbd "C-z") 'undo) ; 【Ctrl+z】 ;; Mac style redo (global-set-key (kbd "C-Z") 'redo) ; 【Ctrl+Shift+z】 ;; Windows style redo (global-set-key (kbd "C-y") 'redo) ; 【Ctrl+y】
For redo, you'll need to install a redo mode. 〔☛ Emacs: Best Undo/Redo Mode〕
;; Linux/Windows style (global-set-key (kbd "<home>") 'move-beginning-of-line) (global-set-key (kbd "<end>") 'move-end-of-line) ;; Mac style (global-set-key (kbd "<home>") 'beginning-of-buffer) (global-set-key (kbd "<end>") 'end-of-buffer)
The cursor movement commands are the most frequently used commands. 〔☛ Emacs's Command Frequency〕. Make them easier to type.
;; make cursor movement keys under right hand's home-row. (global-set-key (kbd "M-i") 'previous-line) (global-set-key (kbd "M-j") 'backward-char) (global-set-key (kbd "M-k") 'next-line) (global-set-key (kbd "M-l") 'forward-char) (global-set-key (kbd "M-u") 'backward-word) (global-set-key (kbd "M-o") 'forward-word) (global-set-key (kbd "M-SPC") 'set-mark-command)
For a more systematic change, see: ErgoEmacs Keybinding.
The ▤ Menu key by default calls execute-extended-command 【Alt+x】 in GNU Emacs on Linux. On Microsoft Windows, you can define it yourself, like this:
;; Set the menu/apps key to do emacs's M-x, if on Windows (cond ((string-equal system-type "windows-nt") (global-set-key (kbd "<apps>") 'execute-extended-command) ) ((string-equal system-type "darwin") t ) ((string-equal system-type "gnu/linux") t ) )
If you are using ErgoEmacs Keybinding, it's already defined for you.
(global-set-key (kbd "<f5>") 'open-unicode-template) (defun open-unicode-template () "Open a file containing frequently used Unicode chars" (interactive) (find-file "~/web/emacs/unicode.txt"))
Set single key open ibuffer, bookmark, or recently opened file list.
;; some number pad keys to open file lists (global-set-key (kbd "<kp-1>") 'recentf-open-files) ; numberic keypad 1 (global-set-key (kbd "<kp-2>") 'bookmark-bmenu-list) (global-set-key (kbd "<kp-3>") 'ibuffer)
Note: On Mac OS X, defining keys for the numeric keypad may not work.
Here's examples of defining keys to open frequently used files.
(global-set-key (kbd "<kp-7> <kp-0>") (lambda () (interactive) (find-file "~/git/xah_emacs_init/xah_emacs_keybinding.el"))) (global-set-key (kbd "<kp-7> <kp-1>") (lambda () (interactive) (find-file "~/web/xahlee_info/js/blog.html"))) (global-set-key (kbd "<kp-7> <kp-2>") (lambda () (interactive) (find-file "~/web/xahlee_info/comp/blog.html"))) (global-set-key (kbd "<kp-7> <kp-3>") (lambda () (interactive) (find-file "~/web/ergoemacs_org/emacs/blog.html"))) ;; more
Related emacs features for opening files are: bookmark, recentf, ido, ibuffer. I use them all. But, nothing beats a simple key to open specific files. All the others you have to type lots of keys, and then eyeball for a second. Define single key to open specific file is muscle memory. 〔☛ Using Emacs's Bookmark Feature〕 〔☛ Tips on Long Term Emacs Productivity〕
Also, see that large useless numberic-keypad on your keyboard? It's your best friend. It adds ≈15 programable keys! 〔☛ Keyboard Shortcut Design: Dedicated keys, Special Buttons, Extra Keys〕
See also a single command to open frequently used files fast: Emacs Lisp: Hotkeys to Open File Fast.
Hotkeys to insert frequently used Unicode characters. You can add few chars, or a systematic character set.
;; example of systematic keys to insert math symbols (global-set-key (kbd "<f9> <right>") "→") (global-set-key (kbd "<f9> a") "α") (global-set-key (kbd "<f9> b") "β") (global-set-key (kbd "<f9> t") "θ")
See: Emacs: How to define Super & Hyper Keys ◇ Emacs: Remapping Keys Using key-translation-map ◇ Emacs & Unicode Tips.
If you do math a lot, you might try a more complete system. See: Emacs Unicode Math Symbols Input Mode (xmsi-mode).
Define keys to insert text you use frequently. Header, footer, signature, copyright template, etc.
(global-set-key (kbd "<f5>") 'insert-my-header) (global-set-key (kbd "<f6>") 'insert-my-footer) (global-set-key (kbd "<f7>") 'insert-signature) ;; example of defining a template insertion command (defun 'insert-paragraph-tag () "Insert <p></p> at cursor point." (interactive) (insert "<p></p>") (backward-char 4))
If you want a systematic template system, you should use abbrev mode 〔☛ Using Emacs Abbrev Mode for Abbreviation〕 or YASnippet. 〔☛ Emacs Templates with YASnippet〕
You can make your mouse's thumb buttons do backward and forward. See: Adding Web Browser Nav Keys to Info-mode.
For general advice on defining keys, see: Emacs: How to Define Keys.