Linux – Copying from one file to another using nano editor
linuxnanounix
How do I copy a few lines from one file to another file using the nano editor?
Best Answer
Assuming you are in pure console mode and can't use the mouse to copy/paste:
Launch nano in multi-buffer mode (nano -F)
CTRL-^ to start your selection.
Arrow key around until you cover all the text you want to copy.
ESC-^ to copy the selection into the cut buffer
CTRL-R ESC-F to open a file into a new buffer
CTRL-U to paste in the opened file
NOTE: To switch between buffers use either ESC-< and ESC-> or ESC-, and ESC-. (the later is helpful if < and > use the same key on your keyboard layout)
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.
ALT or any other keys with Meta-key behaviour could also be used instead of ESC in these commands.
A command line interface to the X11 clipboard. It can also be used for copying files, as an alternative to sftp/scp, avoiding password prompts when X11 forwarding has already been setup.
Best Answer
Assuming you are in pure console mode and can't use the mouse to copy/paste:
NOTE: To switch between buffers use either ESC-< and ESC-> or ESC-, and ESC-. (the later is helpful if < and > use the same key on your keyboard layout)
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.
ALT or any other keys with Meta-key behaviour could also be used instead of ESC in these commands.