Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Vim, paste over text between two parenthesis?

Tags:

vim

shortcut

Something that I find myself doing often is yanking the text between two parenthesis and pasting that over another pair of parenthesis. For example:

foo(int a, int b, int c)
bar(int d, int e)

becomes

foo(int a, int b, int c)
bar(int a, int b, int c)

Is there a quick way in Vim to yank the text from foo and paste it over the text in bar?

like image 238
tomsrobots Avatar asked Jul 20 '15 20:07

tomsrobots


People also ask

How do I paste above a line in Vim?

m` : set a mark in the current cursor position. o<Esc>p : create a new line below and paste the text in this line. O<Esc>P : create a new line above and paste the text in this line.


1 Answers

Yank the content of the first pair of parentheses:

yib

Visually select the content of the second pair of parentheses and put:

vibp
like image 92
romainl Avatar answered Oct 12 '22 02:10

romainl