Question

In vim, command :reg[ister] shows me the list of registers while :ls shows the list of buffers but I'm not sure what the exact difference between registers and buffers is. I think that registers are virtual memory and are used with "(double quotation mark)+{a-zA-Z0-9.%#:-"}+{motion}.

So, what is a buffer? I confuse buffers and registers as of now.

(The only thing I know is that registers are in CPU, buffers in RAM. I need to make both concepts clear to use vim well.

This is what I found about registers in the documentation:

There are nine types of registers:        
1. The unnamed register ""    
2. 10 numbered registers "0 to "9    
3. The small delete register "-    
4. 26 named registers "a to "z or "A to "Z    
5. four read-only registers ":, "., "% and "#    
6. the expression register "=    
7. The selection and drop registers "*, "+ and "~     
8. The black hole register "_    
9. Last search pattern register "/
Was it helpful?

Solution

A buffer generally refers to a file loaded in memory for editing, although there are also buffers that are not associated with a file. The use of buffers allows you to work with multiple files at the same time.

A register is a kind of clipboard, a memory space in which text can be saved. There are several kinds of registers. Some of them are filled automatically when you do some actions, like yanking or deleting text. More information can be found in the help by typing :help registers.

OTHER TIPS

They look similar but are different:

there is a register (act like a clipboard) called unnamed register (")

there is a buffer called [No Name] (contains the content of a non existing file / to be written to a file)

some misuse:

enter image description here

In vim a buffer most ofen refers to an opened file. It is located in RAM and can have unsaved modification in comparison of the file version in your file system.

You can have several buffers at the same time (if you are editing several files). You can then switch between them using "bn"/"bp", delete one using "bd".

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top