Hiding Buffers

Alec Barreto over at The Wumpus Warehouse has an interesting post on hiding buffers. The idea is that there are some buffers that you just don’t care about and never want to see. There are others that you might want to see but only rarely.

Barreto shows how to deal with both these cases. The first is easy. Just rename the buffer to begin with a space. Most (or all?) of the normal buffer switching commands will ignore such a buffer. The only way of accessing these buffers, says Barreto, is to specify its name exactly in a switch buffer command.

I’m not sure why anyone would want to do this. If you really don’t want to see the buffer, just kill it. Hiding it like this just accumulates a bunch of buffers that you don’t need and don’t want. You can see how this can get out of hand if you’re one of those people who restarts monthly or less.

The part dealing with buffers you only want to see occasionally is more interesting. If you’re like me, you’ll learn something new. It turns out that many—but not all—of the buffer changing commands can be asked to call a function to determine if that buffer should be shown or not. Since you can make that function do anything you like, you very fine control over what buffers are shown. Take a look at Barreto’s post for some examples.

When I read Barreto’s post I wondered why it didn’t resonate with me. I’m always doing things that generate buffers I don’t care about. Sometimes I delete them and sometimes they disappear into my buffer list to get reaped on the next reboot. I realized that the reason this works for me is because I use ivy-switch-buffer to switch buffers and that provides me with a vertical list to pick the buffer I want to switch to. It also offers fuzzy search so I never search down the buffer list. I think the list is ordered by recent use so the buffer I want is almost always near the top of the list.

Of course, that’s my workflow. Yours probably differs and Barreto’s methods may make more sense for you. Regardless, Barreto’s post will teach you about switch-to-prev-buffer-skip in case, like me, you didn’t already know about it.

This entry was posted in General. Bookmark the permalink.