Many answers make reference to a "paste buffer" or a "search buffer". Can someone provide a quick primer on what types of buffer there are? Are they interchangeable? Or is it something different?
Those posts are incorrectly using the term
buffer when they mean
As aharris88's answer shows, a buffer typically represents a file that is currently being edited. There are buffers that don't represent a file, but the common case is the representation of a file.
Registers, on the other hand, hold pieces of data for later use. An example that most people use on a frequent basis is the unnamed register (
"). This is the register that, by default, stores the last yank or delete and is the register used, by default, when pasting.
From the vim help:
Summary: A buffer is the in-memory text of a file. A window is a viewport on a buffer. A tab page is a collection of windows. A window is a viewport onto a buffer. You can use multiple windows on one buffer, or several windows on different buffers. A buffer is a file loaded into memory for editing. The original file remains unchanged until you write the buffer to the file. A buffer can be in one of three states: *active-buffer* active: The buffer is displayed in a window. If there is a file for this buffer, it has been read into the buffer. The buffer may have been modified since then and thus be different from the file. *hidden-buffer* hidden: The buffer is not displayed. If there is a file for this buffer, it has been read into the buffer. Otherwise it's the same as an active buffer, you just can't see it. *inactive-buffer* inactive: The buffer is not displayed and does not contain anything. Options for the buffer are remembered if the file was once loaded. It can contain marks from the |viminfo| file. But the buffer doesn't contain text.
You can access this with the command
You can get a list of your current buffers with
You can search through all your current buffers with the command
:bufdo which executes a command in all open buffers like this:
:bufdo %s/pattern/replace/ge | update