Cut, Copy and Paste in nano editor

Three things which we use almost regularly while working on a computer are Cut, Copy and Paste. And, these are not just limited to text editors like nano. We perform these operations on files and directories as well. Here, we would cover how to do Cut, Copy and Paste in nano text editor.

Since, either we cut and paste or copy and paste the text. Therefore, we have decided to divide this article in three sections. First one primarily deals with cut and paste.

Cut and Paste in nano text editor

I. Cut the entire line with Ctrl + K

Place the cursor anywhere on line and use Ctrl + K to cut entire line. The moment you use Ctrl + K, it will cut the text on that line and will leave empty space. Now, to paste it into desired location in the same file. Move the cursor to the desired location and use keyboard shortcut Ctrl + U. It will paste the copied text there.

Note: if you try to paste the contents in some other file opened with nano editor. It won’t paste it there, and will show “Cutbuffer is empty“. That happens because Cutbuffer is a limited buffer, and it has been long deprecated. The Cutbuffer stores the copied text and it is different from clipboard.

If you want to copy text from one nano editor to another. Then, select the text using mouse and right click to copy and right click again in another nano editor to paste. The usual cut, copy & paste operation we do.

II. Copy the entire line with Alt + 6

We can copy the entire line with Alt + 6 and paste with Ctrl + U.

III. Cut or Copy only the selection and paste

What if we want to only cut/copy a part of the text. To select the text, place the cursor at the beginning and press key combination – Alt + A (mark set). Thereafter, use navigation keys on the keyboard to move the cursor. And, to cut use – Ctrl + K or to copy – Alt + 6. Then, we can paste the text with Ctrl + U.

In conclusion, we have covered Cut, Copy and Paste in nano text editor. Also, do remember about the Cutbuffer.