Questions tagged [buffers]

The text you are editing in Emacs resides in an object called a buffer. Each time you visit a file, a buffer is used to hold the file's text. Each time you invoke Dired, a buffer is used to hold the directory listing.

Filter by
Sorted by
Tagged with
68
votes
18answers
32k views

How do I switch buffers quickly?

In vanilla Emacs, I have to do C-x b and then manually type out the buffer name to switch. If I forget the name of the buffer, I have to hit TAB to list possible completions. Is there anything I can ...
51
votes
1answer
2k views

How to view diff when emacs suggests to recover this file?

Sometimes it happens: emacs prompts you about recovering unsaved changes to a file, but you cannot remember if you want those changes or not. Starting at the recover-this-file buffer, is there a way ...
36
votes
7answers
7k views

How do I find text across many open buffers?

Lets say I have 10 buffers open, and I want to find all occurrences of blah in all 10 buffers. How would I do this?
34
votes
6answers
4k views

How to reopen just killed buffer, like C-S-t in Firefox Browser?

Sometimes I accidentally kill a buffer and want to reopen it, just like C-S-t to undo closed tab in Firefox, but there is no built-in command in Emacs, the defun undo-kill-buffer in http://www....
28
votes
2answers
5k views

What's the difference between a buffer, a file, a window, and a frame?

When posing questions on this site, people sometimes talk about "windows" when they mean "frames," and "buffers" or "files" when they mean "windows." So: Q: What is the difference between a buffer, ...
26
votes
4answers
2k views

How to auto-save buffers when Emacs loses focus?

I recently had a Sublime Text user try out Emacs for a while, and he was interested in getting the same auto-save behavior in Emacs. Basically, he wanted all buffers to be saved whenever the frame ...
24
votes
5answers
2k views

Re-open *scratch* buffer

If I accidentally closed the scratch buffer in Emacs, how do I create a new scratch buffer?
22
votes
8answers
4k views

Close all dired buffers

Sometimes my buffer list has 10+ dired windows, and I end up using buffer-menu to manually mark and kill all of them. Is there a faster way to close all open dired windows?
19
votes
2answers
4k views

How can I see the changes made to a modified buffer since the last save?

Given a modified buffer, how can I diff it with the file backing it on disk to see what I've changed?
19
votes
3answers
3k views

How do I clear a buffer completely with elisp?

If I want to delete everything in a buffer with elisp, how do I do that?
17
votes
2answers
2k views

Kill process buffer without confirmation?

I have C-x C-k bound to kill-this-buffer. But when I enter into a buffer which is running a process like Python or MySQL, if I do C-x C-k it asks Buffer "*Python*" has a running process; kill it (...
16
votes
2answers
2k views

Why is (point-min) much more popular than 1?

I searched accross all Emacs Lisp files in Emacs Git repo, and found (goto-char (point-min)) occurs 3621 times and (goto-char 1) occurs 31 times. Personally, I see lots of (point-min) but none 1, even ...
16
votes
3answers
2k views

Why use indirect buffers?

What are the benefits of using indirect buffers? Under what circumstances are they useful?
16
votes
1answer
2k views

How to know my buffer's visible/focused status?

I'm writing an extension that talks to an outside process, so it is a given to lower the amount of 'hey whats up' requests when my buffer isn't focused. So, what is the best way to recognize: When ...
16
votes
3answers
1k views

Set column widths in `ibuffer`

Is there a way to customize the widths of the columns in ibuffer? Specifically, I want to widen the Name column to be able to read more of the buffer names before they get truncated. I have tried ...
16
votes
1answer
1k views

Switch window split orientation, fastest way

Say you have two buffers open like so: ------------------------------------ | | buffer 1 | buffer 2 | | | ------...
15
votes
1answer
3k views

Get content of a buffer

So buffer-string gets the content of the current buffer. But it doesn't allow specifying other buffers. How can I get around that? Do I need something like save-window-excursion to make it work?
14
votes
2answers
3k views

How can I set different font sizes for buffers and for the mode-line?

I have this line in my init.el file to set the size of the font in all frames: (push '(font . "DejaVu Sans Mono-10") default-frame-alist) It works but i'd like to have a bigger font in all buffers ...
14
votes
2answers
2k views

How can I prevent a command from using specific windows?

Typically, I have a frame split into four windows, where two at the bottom are dedicated to my *compilation* and *grep* buffers. When browsing compilation errors, next-error will eventually replace my ...
14
votes
2answers
1k views

How do I do live Markdown previewing as I'm writing it?

How can I do that either in a different buffer or even in the current buffer? I'm trying to do Github README.md and other Github rendering of Markdown (for notes and such),
14
votes
1answer
3k views

Helm swoop on all project files (not just current buffers)

So I'm looking to have helm-swoop look at all files in a project, not just the current set of open buffers. This is so I can use swoop to find all occurrences in a project, mark relevant ones, then ...
13
votes
6answers
784 views

how to get buffers (not just files) to honor auto-mode-alist?

Q: how can I get new buffers to honor the mapping in auto-mode-alist? When finding a file, Emacs compares the file extension to the auto-mode-alist to determine which major mode to use for the file's ...
13
votes
2answers
1k views

How to kill a buffer when it causes Emacs to stop responding? [duplicate]

I use Emacs Dired to manage files. Accidentally, I hit Enter on an image file, Emacs tries to open the image and stop response. Is there a way to kill this process? (Since I am running other ...
13
votes
1answer
921 views

When switching buffers, prevent emacs from automatically switching frame

When I switch buffers, emacs will switch to an existing frame if the buffer is already opened there. I found how to prevent that when switching with ido using : (setq ido-default-buffer-method '...
12
votes
1answer
1k views

Disable minor mode in all open buffers

Often I have many buffers open and, for whatever reason, I no longer wish to use a particular minor mode with them. Is there currently a built-in way to disable a particular minor mode for all open ...
12
votes
2answers
2k views

How do I force a specific buffer to open in a new window?

When committing changes in Magit, it is useful to have the diff view open while adding details about the commit. In Magit, we see the diff in the *magit ..* buffer. When you hit cc while the cursor ...
12
votes
3answers
760 views

Kill buffer when frame is deleted

When I close a frame, I'd like for its buffer to be killed. If the buffer is displayed in other frames, the buffer should not be killed. Do nothing if more than one buffer is displayed in a frame. ...
12
votes
2answers
923 views

Make Buffer List take focus?

How can I make it so that when I press C-xC-b to access the Buffer List that that buffer automatically takes focus instead of having to switch to it manually with C-xo? I can't find a variable that ...
11
votes
2answers
1k views

How can I make ibuffer auto-refresh the list of buffers?

M-x ibuffer Select a buffer Kill that buffer After the buffer is killed, the ibuffer buffer re-appears, but it still shows the buffer name killed in step 3. Is it possible to have ibuffer auto-...
10
votes
5answers
2k views

Revert all open buffers (and ignore errors)

When working on a project under version control with git, I often want to do some things in a shell that affect many of my open files, then revert every buffer that I have open to make sure that I don'...
10
votes
2answers
691 views

make `previous-buffer` and `next-buffer` to ignore some buffers

in Helm I ignore some buffers from showing when using C-x b, I'm looking for a way to make the commands previous-buffer and next-buffer behave the same ignoring some buffers.
10
votes
3answers
854 views

How to add a timestamp to each entry in Emacs' *Messages* buffer?

I depend on the *Messages* buffer a lot, but entries are not timestamped. How can one add a timestamp to each entry in Emacs' Messages buffer? So that something like this: Loading /Users/gsl/lisp.d/...
10
votes
5answers
1k views

Simple method for creating multiple eww buffers

M-x eww prompts for url or keywords and opens a new *eww* buffer. In eww-mode, G is bound to eww, which replaces the content of the single eww buffer. To make multiple buffers for different webpages,...
10
votes
3answers
616 views

How to modify a buffer without undo noticing?

Q: How do I insert/modify text in a buffer without undo noticing? Here's the use case. I have a comment block at the start of every file that, among other things, updates a timestamp for the most ...
10
votes
1answer
505 views

Keep ERC buffers in the background on reconnect

I'm using ERC (with ZNC) as my IRC client. I'm joined to quite a few channels and when I run znc-all all my buffers are restored and the logs are replayed. This is all great. What I find very ...
9
votes
4answers
2k views

How to check whether a buffer is visiting a file?

I'd like to check whether some (say, current) buffer is visiting a file or not. I could say: (if (buffer-file-name) ...) but it seems to be not very elegant - what I'm interested in is only the ...
9
votes
2answers
2k views

How to save a copy of a buffer to a file?

I would like to be able to save a copy (or a snapshot) of a buffer into a file. The behavior would be similar to write-file, except that it would not set the buffer to visit this file. For a usecase, ...
9
votes
2answers
609 views

How can I create a dired buffer listing all open files?

I have a mechanism for burning items to disc from a dired buffer. Unfortunately, the file's I've patched are strewn accross the file system. How can I create a dired buffer from all open files?
9
votes
2answers
1k views

Single mode line for all windows

Is it possible to have only one mode line (sometimes referred as "statusbar") for all windows? I'd like to make this single mode line show information about the currently selected buffer.
9
votes
1answer
191 views

What is the significance of Emacs buffers having names with *earmuffs*?

There are a number of Emacs buffers where their names have "earmuffs", i.e. they have names like *scratch* *R* *ESS* *helm-mode-circe* What is the significance of the earmuffs, and is there a reason ...
8
votes
4answers
2k views

copy contents of current buffer in a temp buffer and operate on that

I need to copy the contents of the current buffer to a temp buffer, set that buffer to a particular major mode to take advantage of its benefits and get the information I need back to the main logic. ...
8
votes
2answers
1k views

Rapidly preview files

Similar to this question, I'd like a tool/minor mode to quickly preview my files by merely having the cursor positioned over them (e.g. the currently selected file is displayed in the active buffer ...
8
votes
2answers
342 views

How should I get the filename of the original buffer in an indirect cloned buffer?

I wanted to look at different portions of a buffer in two different frames, as I have two monitors of different shapes that I can't easily span a single frame over. Some googling led me to use clone-...
8
votes
2answers
179 views

Killed buffer still shown by an earlier Ctrl-x Ctrl-b

I found that a killed buffer is still shown by a buffer created earlier by C-x C-b. How can we get the up-to-date buffer list?
8
votes
4answers
1k views

How can I run a keyboard macro in selected buffers from Ibuffer or selected files from dired?

If I have to do some variable name refactoring, I use ag and multiple-cursors. But when I have to do some code block removal/addition/moving, I use keyboard macros. But I need to switch to each ...
8
votes
2answers
204 views

Kill-buffer prompt with option to diff the changes

The save-some-buffers command prompts to save or ignore each modified file, and also provides an option to diff the modified file against the file it is visiting. I'd like the same behavior from kill-...
8
votes
2answers
1k views

org-babel result to a separate buffer

I use org-babel to generate some reports which can't be automatically processed, and since org is a good outline format, I print the results in org to represent them as trees. I've noticed that ...
8
votes
1answer
264 views

How can I automatically close buffers when the underlying file is deleted?

I leave Emacs running all day, and will often will do a lot of file system manipulation on files that are open in Emacs buffers. For example, I might switch to a different branch in Git that has a ...
8
votes
3answers
829 views

Highlighting text in open (displayed) buffers/windows — searching for text from one buffer in another

Right now, I have my Emacs frame vertically split, and am looking at two different buffers in the two windows. I'd like to go to a word in one buffer, hit some keys, and have the ocurrences of that ...
7
votes
3answers
9k views

Spacemacs: kill buffer and kill window in one command?

Is there a spacemacs command that both closes the window and kills the buffer? In other words, the equivalent of Vim's :q?