Emacs disable easy-keys minor-mode

Table of Contents

1. Abstract

Train yourself to use the proper Emacs movement keys.

2. News

  • 23. July 2012: Made it a proper Emacs package and added it to the marmalade repository.
  • 13. July 2012: Updated the code to not enable the mode in the minibuffer. In the minibuffer the suggested no-easy keys to use are wrong or no alternative exists no-easy key exists.
  • 28. June 2011: I had switched around some 'b' and 'f' keys. Thanks to anonymous commenter for pointing it out.
  • 12. December 2009: Published page.

3. Description

This mode teaches you to use the proper Emacs movement keys in a rather harsh manner.

No-easy-keys disables arrow, end, home and delete keys, as well as their control and meta prefixes. When using any of these keys, you instead get a message informing you of the proper Emacs shortcut you should use instead (e.g. pressing down informs you to use C-n).

The easy keys are not disabled in the minibuffer. The minibuffer has different proper keys replacements than regular buffers and depending on various extensions such as icicles, ido, etc.

4. Github

5. Download

6. Installation

To install, save no-easy-keys.el in your load path or install the package no-easy-keys from the marmalade repository. To initialize no-easy-keys add the following to your .emacs file:

(require 'no-easy-keys)
(no-easy-keys 1)

7. Code

;;; no-easy-keys.el --- Learn the proper Emacs movement keys

;; Copyright (C) 2009-2012 Dan Amlund Thomsen

;; Author: Dan Amlund Thomsen <dan@danamlund.dk>
;; URL: http://danamlund.dk/emacs/no-easy-keys.html
;; Version: 1.0.2
;; Created: 2009-12-12
;; By: Dan Amlund Thomsen
;; Keywords: training, pinky

;; COPYRIGHT NOTICE
;;
;; 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 2 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.

;;; Install:

;; To install, save no-easy-keys.el in your load path and add the
;; following to your .emacs file:
;;
;; (require 'no-easy-keys)
;; (no-easy-keys 1)

;; You can toggle no-easy-keys using 'M-x no-easy-keys'.

;;; Commentary:

;; This mode teaches you to use the proper Emacs movement keys in a
;; rather harsh manner.

;; No-easy-keys disables arrow, end, home and delete keys, as well as
;; their control and meta prefixes. When using any of these keys, you
;; instead get a message informing you of the proper Emacs shortcut
;; you should use instead (e.g. pressing down informs you to use C-n).

;; The easy keys are not disabled in the minibuffer. The minibuffer
;; has different proper keys replacements than regular buffers and
;; depending on various extensions such as icicles, ido, etc.

;;; Code:

(defvar no-easy-keys-minor-mode-map (make-keymap) 
  "no-easy-keys-minor-mode keymap.")

(let ((f (lambda (m)
           `(lambda () (interactive) 
              (message (concat "No! use " ,m " instead."))))))
  (dolist (l '(("<left>" . "C-b") ("<right>" . "C-f") ("<up>" . "C-p")
               ("<down>" . "C-n")
               ("<C-left>" . "M-b") ("<C-right>" . "M-f") ("<C-up>" . "M-{")
               ("<C-down>" . "M-}")
               ("<M-left>" . "M-b") ("<M-right>" . "M-f") ("<M-up>" . "M-{")
               ("<M-down>" . "M-}")
               ("<delete>" . "C-d") ("<C-delete>" . "M-d")
               ("<M-delete>" . "M-d") ("<next>" . "C-v") ("<C-next>" . "M-x <")
               ("<prior>" . "M-v") ("<C-prior>" . "M-x >") 
               ("<home>" . "C-a") ("<C-home>" . "M->")
               ("<C-home>" . "M-<") ("<end>" . "C-e") ("<C-end>" . "M->")))
    (define-key no-easy-keys-minor-mode-map
      (read-kbd-macro (car l)) (funcall f (cdr l)))))

(define-minor-mode no-easy-keys-minor-mode
  "A minor mode that disables the arrow-keys, pg-up/down, delete
and backspace.

Use 'M-x no-easy-keys' to toggle this mode in all buffers except
the minibuffer.

Add (no-easy-keys 1) to your .emacs to enable no-easy-keys by
default."

nil nil 'no-easy-keys-minor-mode-map)

(defun no-easy-keys-hook ()
  (interactive)
  (unless (minibufferp)
    (no-easy-keys-minor-mode 1)))

(define-globalized-minor-mode no-easy-keys
  no-easy-keys-minor-mode no-easy-keys-hook)

(provide 'no-easy-keys)
;;; no-easy-keys.el ends here

8. Comments

Author: Dan Amlund Thomsen

Created: 2025-11-01 Sat 10:08

Validate