vimbuffervim-registers

What is the difference between buffers and registers in vim?


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 "/

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.