Example: I have some text, like this php code
if(empty($condition)) {
// work here...
}
And my default register contains the string “$NewCondition”.
I want to place the cursor inside the first set of parens (...) and perform a command that will result in this:
if($NewCondition) {
// work here...
}
So my question: Is there some way to replace the text inside the parens using the default register?
Most suggestions I’ve found, such as this one, fail when there’s nested parens.
I also know I can name registers, such as "ayi( to yank all text in parens into register a, but I don’t want to have to type two extra characters every time I’m yanking. That’s why I’m asking about the default register.
In an ideal solution the default register would still contain “$NewCondition” when the replace is complete.
vi(to selectempty($condition)"_dto delete it into the blackhole registerPto put the content of the default register before the cursor which is now on the last)I use this a lot so I have this mapping to make the whole thing shorter:
so (with
,as the mapleader) I dovi(,p.As a side note, if your cursor is in the second set of parenthesis you can do
vi(i(to go one level up and so on.