Aaron S. Hawley (aaronhawley) wrote,
Aaron S. Hawley

Cheap tricks in Emacs: Buffers

One nice feature of Emacs, that is as old as Emacs itself, are buffers. Most Emacs users like them because you can have multiple buffers open at once and work on many things at once. And for the record, I'm actually a big fan of the Emacs buffer menu. It looks primitive compared to a tab bar or some such, but it gets things done. But the Emacs buffer list isn't the embarrassing way I use buffers.

I like buffers because they're inexpensive. "Cheap" as in they don't cost a lot to open. I often have arbitrary text with an ephemeral quality that I want to edit. I suppose the scratch buffer is the appropriate place to edit text with a short shelf-life. But I often run `C-x b b' to open a buffer called "b". If I need another I'll often type `C-x b b b' to open another named "bb". Obviously I name the buffers of varying lengths of "b" since "b" is also the last character that's part of the "switch to buffer" command. Since the buffer "b" doesn't exist for switching to, Emacs creates an empty one for you.

Opening a blank buffer opens in the blink of an eye -- faster than it takes to request it. It isn't associated with a file anywhere. Although, you can later, and you may want to if you the file grows to something worth saving. With a blank buffer, you can call an Emacs mode (or minor mode) that is appropriate for the text you're editing. Sometimes a mode like Mail mode or Shell mode are useful. More than likely I'm copying in text from another program to use Emacs's rectangle commands to transform text, or unconditional regular expression replacement or on occasion using keyboard macros.

Opening buffers with no file on disk associated means when you kill the buffer the data is gone -- unless its in the kill-ring. Emacs won't ask if you're sure and can be a bit dangerous, but as I said, use `C-x C-w' to save. This also has the added benefit of using Emacs's always reliable Auto-save feature.

Do folks have other small ways they use Emacs that definitely isn't described in the manual and doesn't necessarily seem correct, but helps them get things done and they wouldn't want to give up?
Tags: emacs, free software, software
  • Post a new comment


    default userpic

    Your reply will be screened

    Your IP address will be recorded 

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.