I was messing with the expression register (:h @=
) and noticed that it is not possible to put text directly in it. The doc says:
The expression register is read-only; you cannot put text into it.
Let's say my buffer contains an operation like that:
1+2+3+4
If I want to get the result in the expression register, I have to do the following:
- yf4: Put the expression into the unnamed register
- "=: Start editing the expression register
- Ctrl-r"enter: Put the content of the unnamed register into the expression register
If the expression register weren't read only I could have done it more easily:
- "=yf4 Select the expression register and put the line into it.
So my question is not about how I could change this behavior but what can explain this implementation?
Is it because yanking directly into the expression register would be "against the Vim way"? Is it because of a technical limitation? Is there another reason?
EDIT
According to the comments, the states of the expression register has changed recently:
My :version
says:
And :h @=
:
But @romainl and @lcd047 told me that the doc says the register is read-write. So I looked up the list of the patches but didn't find one about this change... I have to admit that I'm pretty confused by the situation now.
"=
?:%s/\v\d+$/\=submatch(0)+9/
. But it's also quite useful in other contexts, see Drew Neil's vimcast on it.:h @=
from my Vim 7.4.1905 says "The expression register is read-write."\=
indicated a register. I always thought it was just Vim's way of doing what/e
does in Perl.