Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to copy several lines from a buffer to another in Emacs?

Tags:

emacs

I have two buffers. I want to copy the line 2, 5, 9 and 10 in the first buffer to the second buffer(just append to the second buffer). Except copy and past one line at a time, is there any elegant way to do so?

like image 814
Xing Shi Avatar asked Jan 15 '14 01:01

Xing Shi


1 Answers

You can use the command append-next-kill, bound to C-M-w, to add more text to the latest entry on the kill ring. Use it right before a M-w command, something like this:

  • Mark and copy line 2: C-SPC, C-n, M-w
  • Move to line 5
  • Mark and append-copy it: C-SPC, C-n, C-M-w, M-w
  • Move to line 9...

...and so on.

When you yank the text with C-y, you'll get the lines you selected and appended to the kill ring entry all together.

like image 191
legoscia Avatar answered Nov 15 '22 10:11

legoscia