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?
1 Answer
y
Then change to your other buffer, and
p
-
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.– NahuelMay 25, 2011 at 23:18
-
1@Nahuel: Make sure you use a lower-case
y
to yank the text. An upper-caseY
will yank the entire line. That's if you usedv
or the mouse to highlight the text. If you searched for that text using a pattern, you can yank the matched text withy//e
.– garyjohnMay 26, 2011 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?– NahuelMay 26, 2011 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.– garyjohnMay 26, 2011 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_EVJun 20, 2011 at 18:21