5

Consider the following text:

long foobar=(test);
int  barbar=(something);
char foofoo=();

Suppose I have yanked some chunk of code which I want to place before each opening parenthesis, e.g. funcName. What I currently have to do is just manually enter the addition after selecting e.g. all the ( via CtrlVjj, and then after pressing I, enter funcName (thus disregarding contents of yank register).

Is there a way to instead insert the text before selection, like I'd do using P for a single line?

6

In insert mode, you can use <C-r>" to insert the content of the unnamed register (replace " with b if what you want to insert is stored in register b):

<C-v>jjI<C-r>"
3

You could also use the "normal" command so that it would work even if the ( are not aligned.

Vjj To select the three lines

:normal f(P To execute f( (find first () and P to paste on all three lines.

This makes it also easier to repeat (by selecting other lines, hitting : and Up

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.