Nano is an extremely handy and lightweight text editor that comes with most Linux distributions these days. Today’s tip will teach us how to copy and paste a line or piece of text within a text document.
The first method to copy and paste a line of text is to make imaginative use of the existing ctrl+k cut text and ctrl+u uncut text command. Basically you use ctrl+k once to cut the whole line of text you wish to copy, then use ctrl+u to place it back in the place you cut it from and then move the cursor to where you want the text to appear and press ctrl+u once again.
The second method is to make use of the alt+6 key combination to copy the current line into the buffer. Again, the ctrl+u keypress will paste the buffer content’s back into the document. This can be combined with the alt+m+a key combination which first enables mouse support for nano, then allows you to set a mark to indicate the end of the text you wish to copy. Once the mark has been set, alt+6 will copy it and crl+u will paste it.
And now you know. Nifty.
Matt
Hello. Thanks for your post. The mouse support is very helpful.
I have a question though. I am trying to copy paste from a file in Nano to a text editor outside of nano on my machine (I am running windows using Nano through Putty) and I cannot figure out how to do it. I can select with mouse support enabled everything that I want to in Nano and I can cut it, but when I try to copy into my other text editor, it does not work.
Any help would be super.
Thanks,
Matt
Craig Lotter
I’m afraid that I don’t know how to do that off the bat, but I assume there should be PuTTy functionality to take care of it. Time to read the manual I guess! :)