Ivy Switch Buffer

Since I decided to give swiper, counsel, and ivy a try, I've been paying more attention to abo-abo's posts concerning them. Although I was aware that ivy took control of switch-buffer, I didn't realize how powerful it is.

Abo-abo has an informative post that explains some of those capabilities. When you call ivy-switch-buffer, you get a list of not only the currently open buffers but also bookmarks, recently opened files, and window layouts. Ivy calls the window layouts “views” and for some time you have been able to statically define useful views that you can call up instantly.

With the latest ivy, you can create these view dynamically. Each view captures the window topography, the buffers and any related file in each window, and the position of the point in each window when the view was created. You can have several views with the same window configuration and buffers but with different positions within each buffer. That's very useful.

Because of the way views are named, it's easy to limit your choices to just views when you call ivy-switch-buffer. That makes it especially easy to move directly to the view you want.

Setting all this up is pretty easy. Abo-abo suggests

;; Enable switching to the ``special'' buffers
(setq ivy-use-virtual-buffers t)

;; Create and delete a view
(global-set-key (kbd "C-c v") 'ivy-push-view)
(global-set-key (kbd "C-c V") 'ivy-pop-view)

but you can, of course, use whatever key sequence you like for pushing and popping views.

I like this idea. I can see how it could enable a new and possibly more efficient workflow for at least some of my tasks. Is anyone out there (besides abo-abo) taking advantage of this?

This entry was posted in General and tagged . Bookmark the permalink.
  • One of the things I like about ivy is that I don't really notice it. I love the switch buffer feature that it has recently used file - I use it and appreciate it. I didn't even mention it (or ivy-switch-buffers explicitly) when I made my video because it's just there and i just use it without noticing it.

    • jcs

      It was your post that inspired me to try swiper but I didn't realize how powerful it was. Perhaps you should have a second post that points out its non-obvious capabilities. If I hadn't read abo-abo's post, I would have had no idea.