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.

How do I copy a few lines from one file to another file using the nano editor?

share|improve this question

migrated from stackoverflow.com Feb 8 '13 at 14:54

This question came from our site for professional and enthusiast programmers.

1  
you specified nano in question, but with vim and gedit tag? –  Kent Feb 7 '13 at 23:03

1 Answer 1

up vote 5 down vote accepted

Assuming you are in pure console mode and can't use the mouse to copy/paste:

  1. Launch nano in multi-buffer mode (nano -E)
  2. CTRL-^ to start your selection.
  3. Arrow key around until you cover all the text you want to copy.
  4. ESC-^ to copy the selection into the cut buffer
  5. CTRL-R ESC-F to open a file into a new buffer
  6. CTRL-U to paste in the opened file

NOTE: To switch between buffers use ESC-< and ESC->

An alternative to 2-4 above is to go to the line(s) you want to copy and CTRL-K to delete them, pressing CTRL-K repeatedly to multiple lines to the buffer. When you've cut all the lines you want to copy, CTRL-Y to re-paste them back into the current buffer. Then continue with step 5.

share|improve this answer

Your Answer

 
discard

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.