Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a pattern highlighted and I want to copy all the text highlighted and paste it into another buffer. How can I do that?

share|improve this question

1 Answer 1


Then change to your other buffer, and


share|improve this answer
Maybe I'm doing something wrong. When I do the above, the entire line get yanked and i want to copy only the highlighted text. –  Nahuel May 25 '11 at 23:18
@Nahuel: Make sure you use a lower-case y to yank the text. An upper-case Y will yank the entire line. That's if you used v or the mouse to highlight the text. If you searched for that text using a pattern, you can yank the matched text with y//e. –  garyjohn May 26 '11 at 0:24
@garyjohn Yes I'm doing a pattern search and then working with the results. This time I did yank the highlighted with y//e but only the first match. Can i yank all the words matched at the same time and then paste them, for example, at the end of the file? –  Nahuel May 26 '11 at 1:35
@Nahuel: I can't think of an easy way to do that. You could append each match to the a register, for example, by prefixing the yank with "A, but you'd have to type "Ay//e at each match. The only way I can think of to yank all the matches with one command would be to write a script. –  garyjohn May 26 '11 at 2:46
Not exactly what you are looking for but I will typically use the global commands for this... Basically do :v/pattern/d that will get rid of all non matching lines... then I will yank the remaining lines into the new buffer and undo my previous command... Usually at that point the results are closer to what I want and fairly easy to manipulate further to get the desired results. Hope this helps. –  Neg_EV Jun 20 '11 at 18:21

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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