Emacs: Switch Buffer, ido-mode

Buy Xah Emacs Tutorial. Master emacs benefits for life.
, , …,

This page is a tutorial on switching buffers in emacs. If you don't know what buffers are, first see: Emacs: List Buffers.

When you call switch-to-bufferCtrl+x b】, emacs prompt you for a name, and you can press Tab ↹ for name completion.

Emacs 22 (released in 2007) has a improved switch buffer command called ido-mode. It will show a list of candidates AUTOMATICALLY as you type (no need to press Tab ↹ first).

emacs ido-switch screenshot 2013-03-31
Emacs ido-switch-buffer screenshot

Set ido-mode as Default

To make ido-mode default for switching buffer, put the following in your emacs init:

;; make buffer switch command auto suggestions, also for find-file command
(ido-mode 1)

With the above, the command switch-to-bufferCtrl+x b】 will call ido's version.

Make Ido Suggestions Display Vertically

emacs ido-mode show vertical 2014-10-06
emacs “ido-mode” show vertical
;; make ido display choices vertically
(setq ido-separator "\n")

;; display any item that contains the chars you typed
(setq ido-enable-flex-matching t)

Ido Keybinding

Most useful Ido keybinding:

  1. 】 → Select the next choice.
  2. 】 → Select the previous choice.
  3. 】 → Go to the buffer you switched to last time. 【】 for next.
  4. Enter ↵】 → Use the first choice.
  5. Ctrl+f】 → stop suggestion. useful for creating new file. 【Ctrl+b】 to go back to buffer selection mode.
  6. Ctrl+d】 → switch to open directory mode.
  7. Ctrl+g】 → cancel.

How to create a new file with ido-mode?

in “ido-mode”, press 【Ctrl+f】 to stop suggestion. This is useful when creating new file.

When you want to open a directory, you can press 【Ctrl+d】.

Switching Next/Previous User Buffers

See also: Emacs Lisp: Switching Next/Previous User Buffers

Create New Empty Buffer

Emacs: New Empty Buffer

Like it? Buy Xah Emacs Tutorial.
blog comments powered by Disqus