Emacs: Stop Cursor Going into Minibuffer Prompt

By Xah Lee. Date: . Last updated: .

in emacs minibuffer prompt, when you press the left arrow key, the cursor will move back all the way over the prompt text. This is annoying because user often will hold down 【Alt+b】 to move back by word to edit, and when user starts to type something, emacs will say “This is read-only”. Then you have to manually move cursor out of the prompt. You can try it now by Alt+x query-replace.

Here's how to set the cursor not going into prompt. Put the following in your emacs init.

;; minibuffer, stop cursor going into prompt
 (quote (read-only t cursor-intangible t face minibuffer-prompt))))

( Thanks to Clément Pit-Claudel)

Here's alternative way to do it. Might work better if emacs changed in the future by the time you read this.

  1. Alt+x customize-group.
  2. Type “minibuffer”.
  3. scroll down to “Minibuffer Prompt Properties”.
  4. Check box “Don't Enter”.
  5. Go to the top, click “Apply and Save”
emacs customize-group minibuffer 2016-06-16
M-x customize-group, “minibuffer”.

After that, emacs will insert the following to your init file:

 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
    (read-only t cursor-intangible t face minibuffer-prompt))))

Emacs Customization

  1. How to Set Emacs's User Interface
  2. Emacs: How to Install Packages Using ELPA, MELPA
  3. How to Install Emacs Package Manually
  4. Emacs: How to Define Keys
  5. Emacs: M-x customize Tutorial
  6. Emacs: Set File to Open in a Major Mode
  7. Emacs: Organize Init File
  8. Emacs: Byte Compile Elisp Files
  9. Emacs: What's Hook?
  10. Emacs: Set Environment Variables within Emacs
  11. Elisp: Determine OS, Emacs Version, Machine Host Name
  12. Elisp: Check If a {function, variable, feature} is Defined/Loaded
  13. Emacs: Set Default Window (frame) Size
  14. Emacs: Font Configuration
  15. Emacs: Set Color Theme
  16. Emacs: Save Cursor Position
  17. Emacs: Turn Off Auto Backup; Set Backups into a Directory; How to Delete Backup Files
  18. Emacs: Stop Cursor Going into Minibuffer Prompt
Liket it? Put $1 at patreon. Or Buy Xah Emacs Tutorial. Thanks.