The Expression Register


The expression register is not really a register itself, but it provides a way to evaluate expressions an insert the result into the buffer as if it had been retrieved from a buffer.

This is easiest to understand with a simple example. Starting with an empty buffer we enter insert mode:

Enter INSERT modeiThe value of 2*pi is
The·value·of·2*pi·is·
INSERTTop1:22
 

then access the expression register:

Access the expression register<C-r>=
The·value·of·2*pi·is·
COMMANDTop1:22
 

now we can use the expression register to calculate the value of 2*pi:

Calculate 2*&Pi;2*3.14<CR>
The·value·of·2*pi·is·6.28
INSERTTop1:26
 

The result of the expression (6.28) has been inserted at the cursor location.