3

I usually type M-x buffer-menu to switch buffers in Emacs. How can I do this with a shorter command? Its quite a long string to type.

Thanks!

itsjeyd
  • 5,070
  • 2
  • 30
  • 49
Jojje
  • 1,749
  • 3
  • 25
  • 44
  • As a more general point: C-h f _function name_ will bring up help for the function, including any keys it may be bound to. – stsquad Oct 03 '12 at 08:24

5 Answers5

6

C-x C-b

As stated here

Federico klez Culloca
  • 26,308
  • 17
  • 56
  • 95
  • Yes thanks, the thing I dont like with it though is that the screen is split in two parts. – Jojje Aug 18 '10 at 16:50
6
  • You can use C-x b to change buffers. You have to enter the first few letters of the buffer name, and of course you can use completion. If you press TAB (the most useful key in Emacs), a list of (matching) buffers appears. You can click in this list to switch to a buffer.

  • You can bind buffer-menu to a key. Pick a key that's not used for another command — let's say f12 — and add the following line to the file ~/.emacs:

    (global-set-key (kbd "<f12>") 'buffer-menu)
    
  • There are many other interfaces to changing buffers in Emacs, and they can be significantly more efficient than C-x b and C-x C-b. Since this tends to be a very personal choice, I recommend you experiment with a few and keep the one(s) you feel most comfortable with.

Gilles 'SO- stop being evil'
  • 104,111
  • 38
  • 209
  • 254
  • Just out of curiosity: Why did you roll back the edit I made? – itsjeyd Apr 09 '14 at 21:50
  • @itsjeyd `C-x b` and the like is the standard notation for key bindings in Emacs. Please stick to that notation when dealing with Emacs keys. Use `kbd` tags when refering to actual keyboard keys, but use it properly: for example, pressing `Ctrl+X` then `B` on the keyboard (I'm showing the raw HTML here as the HTML tag can't be used in a comment) generates the Emacs key sequence `\`C-x b\``. – Gilles 'SO- stop being evil' Apr 09 '14 at 21:53
  • Interesting. I always assumed that a sentence like "Press `C-x b` to change buffers" *was* referring to (a sequence of) actual keyboard keys being pressed. I wouldn't use the `` notation in a context that refers to Elisp code. Is there a Meta SO post (or an entry in the Help section I might have overlooked) that defines these standards? Again, just curious, as I have seen a number of posts that utilize the available markup options in a different (but consistent) way than you are suggesting. – itsjeyd Apr 09 '14 at 22:01
  • @itsjeyd No idea about a meta post. The example in the [help](http://stackoverflow.com/editing-help#html) is `ctrl+alt+del`, not `ctrl-alt-del`, but that's not very conclusive. But having written several posts where I explained the difference between physical keystrokes and application keys (e.g. modifier keys, ESC/Alt, …), I can attest that the distinction is useful. – Gilles 'SO- stop being evil' Apr 09 '14 at 22:10
4

I'd highly recommend switching to a mode designed for efficient buffer switching.

If your version of Emacs is recent enough (22+):

M-x ido-mode

and then:

C-x b

to switch buffers, with incremental substring matching, C-s and C-r rotate forward and backwards through the matches.

If you have an older version of Emacs, it should have:

M-x iswitchb-mode

and then, as with ido-mode:

C-x b

opens up the minibuffer to let you choose the buffer to switch to.

Gilles 'SO- stop being evil'
  • 104,111
  • 38
  • 209
  • 254
R. P. Dillon
  • 2,780
  • 1
  • 18
  • 20
2

Bind C-x C-b to buffer-menu. There is no sense leaving it bound to list-buffers. list-buffers is just a eunuch version of buffer-menu. ;-)

And you might want to try this: http://www.emacswiki.org/emacs/BufferMenuPlus

Drew
  • 29,895
  • 7
  • 74
  • 104
1

Try bs-show (in my opinion a way better than C-x C-b). You can bind it to F9 by adding this to .emacs:

(global-set-key (kbd "<f9>") 'bs-show)
Session13
  • 11
  • 1