emacsorg-modeido

In GNU Emacs, how to create new empty buffer with one keystroke?


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.)


Solution

  • 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)