Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Going back to a previous buffer in emacs

Tags:

emacs

I used C-x u and the screen I was typing on disappeared, so I tried creating again on the second question but it says that file already exists; how do go back to the one I created in the first question?

like image 759
Emma Maina Avatar asked Nov 30 '25 03:11

Emma Maina


2 Answers

There's a suite of options based on what you're trying to accomplish:

  1. Ctrl-x <left> jumps to your previous buffer, can be repeated to keep popping stack frames

  2. Ctrl-x b opens a prompt in the minibuffer. The default option is the prior buffer, but you can use <up>/<down> keys to browse the prior stack of buffers

  3. Ctrl-x Ctrl-b opens *Buffer List* where you can see all buffers and select the one you want

like image 60
Matt Kneiser Avatar answered Dec 03 '25 01:12

Matt Kneiser


If you want to go back to the previous buffer, probably you could use Ctrl-X <left> keybinding. If you want to go back to a previous window, you could try Ctrl-C <left> with winner-undo.

Edit: To use Ctrl-C <left>, you should enable winner-mode first:

;;;Winner mode is an Emacs built-in package that lets you undo and redo window
;;;configurations. Incredibly useful since I keep splitting and merging windows
;;;https://www.emacswiki.org/emacs/WinnerMode
(when (fboundp 'winner-mode)
  (winner-mode t))
like image 41
ramsay Avatar answered Dec 02 '25 23:12

ramsay



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!