Emacs: Friend or Foe?
There are several small items that you might want to configure to depart from Emacs' default behavior. I'm going to list the code for these briefly below; none of them involve new concepts other than those discussed above. The comments should describe these customizations adequately.
;; Allow M-j, M-k, M-h, M-l to move cursor, ;; similar to vi. (global-set-key "\M-j" 'next-line) (global-set-key "\M-k" 'previous-line) (global-set-key "\M-h" 'backward-char) (global-set-key "\M-l" 'forward-char) ;; Commonly used buffer commands, requiring ;; less use of CTRL ;; (For the ergonomically-minded.) (global-set-key "\C-xf" 'find-file) (global-set-key "\C-xs" 'save-buffer) ;; Open a line below the current one; as in "o" in vi (defun my-open-line () (interactive "*") (end-of-line nil) (insert ?\n)) (global-set-key "\C-o" 'my-open-line) ;; Make the current buffer the only visible one, ;; and recenter it. (defun my-recenter-frame () (interactive "") (delete-other-windows) (recenter)) (global-set-key "\C-l 'my-recenter-frame) ;; Save all buffers and kill Emacs, without prompting (defun my-save-buffers-kill-emacs (arg) (interactive "P") (save-buffers-kill-emacs t)) (global-set-key "\C-x\C-c" 'my-save-buffers-kill-emacs) ;; Preserve original save-buffers-kill-emacs, ;; in case we don't want ;; to save what we were doing (global-set-key "\C-x\C-x" 'save-buffers-kill-emacs) ;; Real Programmers don't use backup files (setq make-backup-files 'nil) ;; But Real Programmers do use RCS. Includes ;; rcsid definition in a C source file (defun my-c-insert-rcsid () (interactive "*") (insert "static char rcsid = \"@(#)$Header$\";")) (define-key c-mode-map "\C-c\C-x" 'my-c-insert-rcsid) ;; Finally, prevent next-line command from adding ;; newlines at the ;; end of the document. Instead, ring the bell when ;; at the end of ;; the buffer. (setq next-line-add-newlines 'nil)
I hope that this whirlwind tour through the world of Emacs customization has been useful, or, at least entertaining. I've found many of the above modifications to be invaluable. Remember the old saying: Have Elisp, will travel.
That being said, it's back to vi for a while.
Matt Welsh (email@example.com) is a programmer at the Cornell University Robotics and Vision Laboratory. He spends his free time homebrewing virtual beer and playing the blues.
Webinar: 8 Signs You’re Beyond Cron
11am CDT, April 29th
Join Linux Journal and Pat Cameron, Director of Automation Technology at HelpSystems, as they discuss the eight primary advantages of moving beyond cron job scheduling. In this webinar, you’ll learn about integrating cron with an enterprise scheduler.Join us!
|Play for Me, Jarvis||Apr 16, 2015|
|Drupageddon: SQL Injection, Database Abstraction and Hundreds of Thousands of Web Sites||Apr 15, 2015|
|Non-Linux FOSS: .NET?||Apr 13, 2015|
|Designing Foils with XFLR5||Apr 08, 2015|
|diff -u: What's New in Kernel Development||Apr 07, 2015|
- Drupageddon: SQL Injection, Database Abstraction and Hundreds of Thousands of Web Sites
- Play for Me, Jarvis
- Non-Linux FOSS: .NET?
- Designing Foils with XFLR5
- Not So Dynamic Updates
- Flexible Access Control with Squid Proxy
- Users, Permissions and Multitenant Sites
- New Products
- diff -u: What's New in Kernel Development