5

How do I create a new empty buffer with a single keystroke? I can create a new buffer with C-x b and then entering a name. (I use ido-mode, so if I just hit RET it opens the most recent buffer.)

I'd like a command to open a new untitled buffer with a single key binding, e.g. s-t.

(Similar to the new-tab command in Aquamacs.)

incandescentman
  • 6,168
  • 3
  • 46
  • 86
  • Why not check the definition of `new-tab` in Aquamacs? It's probably compatible. – phils Mar 09 '14 at 23:10
  • Here is a slight variation of the answer below that does not need a global variable: http://stackoverflow.com/a/21071757/2112489 – lawlist Mar 09 '14 at 23:58

1 Answers1

4

As YoungFrog pointed out, it can be easier to just generate a new buffer (which will get automatically get a number appended to it when it exists):

(defun new-buffer ()
  (interactive)
  (switch-to-buffer (generate-new-buffer "buffer"))
  )

(global-set-key (kbd "\s-t") 'new-buffer)
PascalVKooten
  • 20,643
  • 17
  • 103
  • 160