Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim replace inside quotes

Tags:

vim

Many times I find that I will will want to yank the content between quotes and paste them inside another set up of quotes. For example, take this code for instance.

var foo = 'bar',
    baz = 'buz';

I would normally do a yi' inside of 'bar' to yank the word bar.

How do I replace buz with my yank? I know one option is to do a di'"0P, I just wonder if there is an easier solution I'm overlooking.

like image 476
Shane Stillwell Avatar asked Nov 06 '12 02:11

Shane Stillwell


1 Answers

With your cursor anywhere on the word buz, vi'p to visually select inside the quotes and then put the contents of the most recent yank.

like image 97
Mark Rushakoff Avatar answered Oct 19 '22 20:10

Mark Rushakoff