Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 "/
like image 205
StarMomo Avatar asked Nov 23 '13 17:11

StarMomo


People also ask

What is difference between register and buffer?

1. Registers is a small amount of fast storage element into the processor. Buffer is used to compensate for difference in speed between two processes that exchange or use data.

What are buffers in Vim?

A buffer is an area of Vim's memory used to hold text read from a file. In addition, an empty buffer with no associated file can be created to allow the entry of text. The :e filename command can edit an existing file or a new file.

What is registers in Vim?

Vim registers are spaces in memory that Vim uses to store some text or operation details. Each of these spaces has an identifier so that it can be accessed later. When we want to reference a Vim register, we use a double quote followed by the register's name.

What is the use of buffer register?

Ans: The Buffer Register prevents the high speed processor from being locked to a slow I/O device during a sequence of data transfer or reduces speed mismatch between faster and slower devices.


1 Answers

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.

like image 65
jdc Avatar answered Sep 22 '22 00:09

jdc