0

“hello world”
“need be replaced by hello world”

What I do is put cursor in first line, issue command yi" and then move cursor to second line, issue vi"p

I want to know is there any more convenient way to do this task

1
  • Sure: Ypjdd ;) But seriously, not really. At least not if you and I have the same definition of convenient. (Are you just referring to number of keystrokes?) That's a pretty short pair of commands, if you ask me. You're leveraging the power of Vim well.
    – B Layer
    Commented Nov 17, 2021 at 8:00

1 Answer 1

1

Try defining some normal mode mappings in your ~/.vimrc. For this example, let's sacrifice the builtin gq and gQ functionality.

" Yank the text inside quotes to the 'a' register
nnoremap gq "ayi"
" Replace the text inside quote from the contents of the 'a' register
nnoremap gQ vi""ap

Now you can use gq to yank the text inside quotes and gQ to replace the text inside quotes.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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