How to Cut, Copy and Paste Text in Nano Editor

The cut, copy, and paste file editing operations are key in the mastery of Linux file management. On a graphical text editor like LibreOffice Writer, the implementation of these file editing operations are a no-brainer.

However, the nano text editor offers some file editing flexibility not evident in graphical file editors like LibreOffice Writer. For instance, it is easier to navigate to various file paths and open them via the nano editor than it is to achieve the same objective using a graphical text editor.

This tutorial will show us how easy it is to achieve cut, copy, and paste text operations while using the nano text editor in Linux.

Problem Statement

For this tutorial to be interactive and well understood, we need a reference file for demonstrating the cut, copy, and paste operations we will be addressing through the nano editor.

Consider the following sample file:

Nano Sample File in Linux
Nano Sample File in Linux

Cut and Paste Text in Nano Editor

The implementation of the cut text operation can be interpreted in the following manner. The cut text operation deletes the highlighted line entry from the currently open file.

For instance, in the above open file, we can cut the line entry “I am a file called new_file.txt!” in the following manner.

The first step is to position the cursor on the line entry you wish to cut using the keyboard arrow key.

Position Cursor in Nano Editor
Position Cursor in Nano Editor

From here, use the keyboard key combination [Ctrl]+6 to mark the text selection starting point.

Mark Text Selection in Nano Editor
Mark Text Selection in Nano Editor

Now use the keyboard arrow keys to highlight the text you wish to cut.

Highlight Text in Nano Editor
Highlight Text in Nano Editor

To cut our text, we will use the keyboard key combination [Ctrl]+k.

Cut Text in Nano Editor
Cut Text in Nano Editor

To paste our cut text, navigate to the file entry position where you would like to paste the cut text. It could be the same file or on another file opened by the nano editor.

Once you are at the right pasting position, use the keyboard key combination [Ctrl]+u to paste the cut text content.

Paste Text in Nano Editor
Paste Text in Nano Editor

Copy and Paste Text in Nano Editor

Text copying operation only duplicates a highlighted line entry on a text file. To copy the text “I am a file called new_file.txt!” we will follow the following steps.

Position the cursor on the line entry you wish to copy using the keyboard arrow key.

Position Cursor Line in Nano Editor
Position Cursor Line in Nano Editor

Use the keyboard key combination [Ctrl]+6 to mark the text selection starting point.

Mark Text Selection in Nano Editor
Mark Text Selection in Nano Editor

Use the keyboard arrow keys to highlight the text you wish to copy.

Highlight Text in Nano Editor
Highlight Text in Nano Editor

To copy our text, we will use the keyboard key combination [Alt]+6.

Copy Text in Nano Editor
Copy Text in Nano Editor

To paste the copied text, navigate to the preferred file position and implement the keyboard key combination [Ctrl]+u.

Copy and Paste Text in Nano Editor
Copy and Paste Text in Nano Editor

Once you are through with cutting or pasting your text, you can save (Ctrl+o) and exit (Ctrl+x) your file.

In our next article guide, we will address how to search and replace text in nano editor.

Tutorial Feedback...
Was this article helpful? If you don't find this article helpful or found some outdated info, issue or a typo, do post your valuable feedback or suggestions in the comments to help improve this article...

Got something to say? Join the discussion.

Have a question or suggestion? Please leave a comment to start the discussion. Please keep in mind that all comments are moderated and your email address will NOT be published.