Saturday, August 2, 2014

Duplicate line without losing unnamed register?

Hi All,
This is a ViM ninja question. What is the most efficient way of duplicating a line without overwriting the unnamed register?

For example, imagine the following two lines in a buffer:

this_is_a_really_long_word
<bean id="duplicate_this_line" class="..." scope="prototype" />

What'd I'd like to do is yank the "long" word (yiw), and then duplicate the <bean line, and then replace the id of the duplicated line with the yanked word in unnamed register. This of course doesn't work, because the duplicate operation (yyp), overwrites both the unnamed register and the copy ("0) register.

I'm a sloppy yanker, and never remember to use registers. But if I did, then of course yanking the long word into a register ("ayiw) would be the most efficient way.

However, after the fact that I've already yanked the word into the unnamed register, the only somewhat lengthy solution I've found is to copy the unnamed register into a named register (:let @a=@"), and then proceed with duplicating the line and changing the id attribute (vi""ap).

Anyone have a better solution?

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment