Home > linux > Life with Emacs #2: Buffers and Note-taking

Life with Emacs #2: Buffers and Note-taking

November 27th, 2008

Emacs might be thought of as a programmer’s editor, but it works just as well as a text editor. But Brad, isn’t it a bit overkill to use Emacs for text editing? I’m a fan of getting as much use as I can out of an editor, and what better way than this? The buffers are one of my favorite things about Emacs. Sure, Vim has buffers, too, but I like the navigation in Emacs better. In my work, I deal with support tickets. So, when I take on a ticket, the first thing I’ll do is this C-x C-f 1111111, where 1111111 represents the ticket number I’m working on. Then from that point, as I gather information, I copy things from one window to another into that buffer to keep it handy. Once in a while, I’ll save the buffer with C-x C-s so I don’t risk losing the notes. This is definitely an easy way to keep my notes separated by ticket, and if I happen to be working on multiple tickets, I can switch buffers with C-x b then the buffer name.

By default, Emacs starts you out in a scratch buffer. I keep this open and use it to copy / paste tidbits of information that I might need later in the day, such as commands or even some time tracking. It truly is a scratch buffer in this case, and it works wonders. That’s it for this week. I was going to share my cheatsheet, but sadly I lost it. I’ll have it for next week. For now, I leave you with a summary of commands I used this week. For each of the commands, please note that C is the Control key, and M is the Meta, or ALT, key.

Emacs Commands Used

  • C-x C-f filename – Create a new file called filename. Can include paths. Example: C-x C-f /home/fubar/temp.txt
  • C-x C-s – Save the current buffer
  • C-x b – Switch to buffer. Presents a default buffer name, but type the name of the buffer you want.

linux , ,

  1. November 28th, 2008 at 07:30 | #1

    Since emacs 22. something, you can also cycle buffers with C-x . I use that a lot.

  2. November 28th, 2008 at 08:19 | #2

    Not sure why I didn’t find that sooner, but thanks! That’ll definitely be something I use for sure.

  3. November 28th, 2008 at 09:50 | #3

    @Nathan: That doesn’t seem to work in my Emacs Snapshot (that which is set to become Emacs 23, from CVS, in Ubuntu). Anything special required to set that up? “C-x .” in my Emacs responds with “fill-prefix cancelled”.

    @Brad: If you open a file and it’s the wrong one, you can use “C-x C-v” to “find-alternate-file” (or, of course, “M-x find-alternate-file”). This is really useful when you are working pretty deep in the directory tree, and you make a typo in a filename; it will then close the file you accidentally opened, and open the alternate that you specify.

  4. December 3rd, 2008 at 10:45 | #4

    Michael,

    Sorry, his blog software ate the fact that I have the word “arrows” in less than, greater than symbols. so you use left and right arrow.

    It works in that version of Emacs as that is what I use.

  5. Brad
    December 3rd, 2008 at 14:26 | #5

    Yeah, Wordpress has a nasty habit of doing that for one reason or another. I figured that out too, but forgot to post a response.

  1. No trackbacks yet.