Emacs: Ido Mode
ido-mode enhanced emacs switch buffer command and opening file command.
Ido mode is part of emacs.
When ido mode is on, when you press the keys to switch buffer or open file, emacs will call ido's version.
ido-switch-buffer will show a list of candidates AUTOMATICALLY as you type (no need to press Tab first).
ido-modeto toggle it on/off.
ido-switch-buffer【Ctrl+x b】 to switch buffer.
ido-switch-buffer is called, it will prompt for a choice of buffer name.
Here's the most useful ido keys when in the prompt:
- 【→】 → Select the next choice.
- 【←】 → Select the previous choice.
- 【↑】 → Go to the buffer you switched to last time. 【↓】 for next.
- 【Enter】 → Use the first choice.
- 【Ctrl+f】 → stop suggestion. useful for creating new file. 【Ctrl+b】 to go back to buffer selection mode.
- 【Ctrl+d】 → switch to open directory mode.
- 【Ctrl+g】 → cancel.
How to create a new file with ido-mode?
ido-switch-buffer, then press 【Ctrl+f】 to stop suggestion. This is useful when creating new file.
When you want to open a directory, press 【Ctrl+d】.
Ido Mode Setup
You can setup ido mode to display choices vertically, and turn on flex match.
Put this in your emacs init file:
(progn ;; make buffer switch command do suggestions, also for find-file command (require 'ido) (ido-mode 1) ;; show choices vertically (if (version< emacs-version "25") (progn (make-local-variable 'ido-separator) (setq ido-separator "\n")) (progn (make-local-variable 'ido-decorations) (setf (nth 2 ido-decorations) "\n"))) ;; show any name that has the chars you typed (setq ido-enable-flex-matching t) ;; use current pane for newly opened file (setq ido-default-file-method 'selected-window) ;; use current pane for newly switched buffer (setq ido-default-buffer-method 'selected-window) ;; stop ido from suggesting when naming new file (define-key (cdr ido-minor-mode-map-entry) [remap write-file] nil))
;; big minibuffer height, for ido to show choices vertically (setq max-mini-window-height 0.5)
Stop ido Suggestion When Writing File
When you call
write-file 【Ctrl+x Ctrl+w】
(aka “save as”), when ido is on, it'll make suggestions.
This is annoying because usually you don't want the name to be a existing file.
Here's how to stop ido suggestion when Alt+x
write-file, put this in emacs init:
(require 'ido) ;; stop ido suggestion when doing a save-as (define-key (cdr ido-minor-mode-map-entry) [remap write-file] nil)
ido is written by Kim F Storm. Ido started in 1996. Kim is also author of
cua-mode. (cua started in 1997) Kim's home page is
Ido became part of emacs 22 (released in 2007).
See also: Emacs: icomplete vs ido mode
Open File topics
- Emacs: File Manager, dired
- Emacs: Bookmark Tutorial
- Emacs: Open Recently Opened File
- Emacs: Open File Fast
- Emacs: Open Last Closed File
- Emacs: Open File Path Under Cursor