Skip to main content

C'est la Z

Using Emacs - 4 - Buffers

Now that we're past the intro material, we'll start looking at emacs features one at a time. This will let you focus on using the one feature we're covering, fit it into your work flow, and really get comfortable with it.

This time we'll dive into using Emacs effectively with buffers.

Watch the video and then make a real effort to use buffers over the next few emacs sessions. Before you know it, they'll be a natural part of your work flow.

The idea of incrementally learning a tool this way seems to be called developing micro-habits and I first read about the idea from Sacha Chua who is an amazing member of the emacs community.

When seeing beginners, I'll frequently observe this work flow:

  • Open a terminal
  • Load emacs on a file
  • Edit the file
  • Save and quit emacs
  • Try to compile and run the program (since usually this is in a programming class)
  • repeat

If the beginner needs to see multiple files at once, they fire up multiple separate emacs.

All of this causes me physical pain.

In emacs, your editor can load several buffers at once, each associated with a separate file. You can quickly switch between them, search across them, and more. The video will get you started.

The video also mentions ido mode. To set up ido mode, add the following code to your init.el:

(setq ido-enable-flex-matching t)
(setq ido-everywhere t)
(ido-mode 1)

And here's a great little write up on it by Mickey Petersen:

https://www.masteringemacs.org/article/introduction-to-ido-mode

As I mentioned in the video, I actually use another mode for completions (swiper), which I'll cover in a future video and another popular option is helm which we'll also cover.

For buffers, the keys to remember are:

KeyCommand
C-x bswitch-buffer
C-x C-blist-buffers

To use ibuffer, which is more powerful than list-buffers you can add either:

(defalias 'list-buffers 'ibuffer) ; make ibuffer default

Or if you want to open ibuffer in another Window:

(defalias 'list-buffers 'ibuffer-other-window) ; make ibuffer default

Here are a couple of useful links on ibuffer and buffer switching:

Finally, if you like a tab bar, you can add the following to your init.el:

(use-package tabbar
:ensure t
:config (tabbar-mode 1)
)

There's also a package tabbar-ruler which is supposed to make the tabbar look nicer but since I don't use the tabbar at all, I haven't checked it out.

Hope this gets you using emacs more effectively.

Stay tuned for our next video on window management.

Relevant links:

comments powered by Disqus