M-x all-things-emacs

Package Faves: iswitchb

April 24th, 2007 by Rob Christie · 102 Comments

This is the start of a series on our favorite emacs packages. Some of these packages are part of emacs core, some aren’t (but we could argue should be). I use iswitchb-mode at least a hundred times a day. iswitchb is one of the features of emacs that I rave about whenever I try to explain why I am still using a 30-year old editor. From the package commentary:

As you type in a substring, the list of buffers currently matching the substring is displayed as you type. The list is ordered so that the most recent buffers visited come at the start of the list. The buffer at the start of the list will be the one visited when you press return. By typing more of the substring, the list is narrowed down so that gradually the buffer you want will be at the top of the list. Alternatively, you can use C-s and C-r to rotate buffer names in the list until the one you want is at the top of the list. Completion is also available so that you can see what is common to all of the matching buffers as you type.

The key stroke C-x b brings up the iswitchb mini-buffer, and with a few key strokes the file you want is open. My normal mode of operation is to load the project I am working on into the emacs file name cache, and then use iswitchb to switch between the files. In order to use iswitchb in this manner you will need iswitchb-fc, and a means for populating the file name cache.

iswitchb in action, 1

Some of the nice features of iswitchb include filtering out buffers that you don’t want to see, and limiting how many files are shown in the minibuffer by customizing the iswitchb-max-to-show variable. Additionally, you can kill a buffer from within iswitchb by typing C-k. The following is a snippet from my .emacs:

;; iswitchb
(require 'iswitchb)  
(iswitchb-mode 1)
;; iswitchb ignores
(add-to-list 'iswitchb-buffer-ignore "^ ")
(add-to-list 'iswitchb-buffer-ignore "*Messages*")
(add-to-list 'iswitchb-buffer-ignore "*ECB")
(add-to-list 'iswitchb-buffer-ignore "*Buffer")
(add-to-list 'iswitchb-buffer-ignore "*Completions")
(add-to-list 'iswitchb-buffer-ignore "*ftp ")
(add-to-list 'iswitchb-buffer-ignore "*bsh")
(add-to-list 'iswitchb-buffer-ignore "*jde-log")
(add-to-list 'iswitchb-buffer-ignore "^[tT][aA][gG][sS]$")
;; iswitchb-fc
(require 'filecache)
(load "iswitchb-fc")

There are other packages out there that do the same thing and even more. Even though I love iswitchb, I have been meaning to try icicles and/or the ido package since they seem to provide the same functionality on steroids. If you are an advocate of one of these other packages, I hope to hear from you. If you are not using any of these packages on an hourly basis then start today. The package is indispensable.

Tags: faves · misc · reviews

102 responses so far ↓

  • 1 piyo // Apr 24, 2007 at 3:01 pm

    I was a frequent user of iswitchb, but I’ve switched to ido. I’m not an expert of ido, though. I don’t turn on everything, just the ido buffer mode.

    I do however hook up recentf and ido together. This lets you match on files over your history instead of just buffer. I got that tip from xsteve: http://www.xsteve.at/prg/emacs/power-user-tips.html
    Recentf’s file listing page now seems so slow to me.
    I think this idea could substitute loosely for the above mentioned iswitchb-fc.

  • 2 stiff // Apr 24, 2007 at 5:02 pm

    The nice thing about ido-mode is that it offers similar completion for commands other than switching buffers, for example you can use it when finding files with C-x C-f. You can also interface it from your own elisp code.

  • 3 Luke Hoersten // Apr 24, 2007 at 6:18 pm

    Awesome suggestion! I use emacs on a ton of computers so I like to use the stuff built into emacs. I showed my friend who uses kate as an editor how fast I can switch tabs now… he just didn’t understand how cool it was. Then we raced =)

  • 4 Amit Patel // Apr 24, 2007 at 6:37 pm

    Also try out icomplete-mode. It’s like iswitchb, but for minibuffer input (example: M-x commands).

  • 5 Phil! // Apr 24, 2007 at 8:50 pm

    I’ve been using iswitchb for a while, and I love it. I tried ido, but it actually interfered with one way in which I use emacs: when programming in a given project, I like to preload all of the source files in the project’s directory and just jump between them with C-x b. (Among other things, having everything loaded makes dabbrev-expand work very nicely.) Consequently, I often do ‘C-x C-f ~/directory/*.pas’. ido always interpreted that as a single file, while the standard emacs functions treat it as a globbing pattern. Thus, I stick with iswitchb.

  • 6 John Wiegley // Apr 25, 2007 at 3:01 am

    iswitchb.el can also match against files you have recently visited, and which are not currently open (I call the concept “virtual buffers”, since you should be able to switch to recently used files as if they were just dormant buffers).

    To enable this usage, just turn on recentf, then set `iswitchb-use-virtual-buffers’ to t. You can use the customize interface to do both.


  • 7 Nikolaj Schumacher // Apr 25, 2007 at 9:16 am

    Can’t / certainly don’t want to remember my time before iswitchb. :)

    There is a great function in the comments of iswitchb.el named `iwitchb-exclude-nonmatching’. It allows to search for stuff like “.el” first, in order to limit the number of visible buffers.

  • 8 Michael Olson // Apr 25, 2007 at 11:13 pm

    ido is my preferred buffer-switching package. I seem to remember that it handles spaces in buffer names a bit more intelligently than iswitchb does.

  • 9 Christophe Thibaut // Apr 26, 2007 at 5:34 am

    Sounds really interesting, but when I type M-x iswitchb-mode , emacs tells Symbol’s function definition is void: define-obsolete-variable-alias. I don’t know what it means. Did you ever get that message while trying to use the package? What did you do, then? Thanks in advance.

  • 10 Stian Selnes // Jun 9, 2007 at 10:28 am

    In ido-mode, if you hit ‘C-x C-f C-f’ you get the “normal” find file function. So to open all your files at once, just do ‘C-x C-f C-f ~/directory/*.pas’

  • 11 mark // Sep 4, 2007 at 11:32 pm

    first: nice blog!
    then: as for a buffer-manager: anything.el has been a nice companion so far


  • 12 mark // Sep 4, 2007 at 11:35 pm

    first: nice blog!
    then: as for a buffer-manager: anything.el has been a nice companion so far. see bills intro to it under Quicksilver for Emacs:anything.el


  • 13 Rob Christie // Sep 5, 2007 at 1:37 am


    Thanks for the pointer. I will have to check out anything.el. I love Quicksilver.

  • 14 user // Sep 7, 2007 at 8:10 pm

    The linked blog entry doesn’t mention anything-config.el which is really nice and has lots of predefined configurations for anything.el

    See here for more information if you want to try it:


  • 15 samuel // Sep 9, 2009 at 2:53 am

    Is there a way to make c-x b in ido also look at recentf?

  • 16 Rob Christie // Sep 9, 2009 at 12:49 pm

    @samuel – Have you tried any of these options from the Emacs Wiki

  • 17 Smumpsoox // Feb 3, 2011 at 5:24 am

    We don’t believe we sale our premium medications that cheap! Hurry up, guys! That’s what i want to say here.