Copying text in Nano uses keyboard shortcuts, not your mouse
Nano is a text editor that runs inside your terminal or command line — the black window where you type commands to your computer. Unlike word processors, Nano does not let you click and drag to select text. Instead, you use keyboard combinations to mark a section and copy it to a temporary storage area called the clipboard.
The most common way to copy in Nano is to mark the start of your text with Ctrl+6, move your cursor to the end of what you want, and then press Alt+6 to copy it. The text stays in your clipboard until you paste it somewhere else or close Nano.
Key Takeaways
- Press Ctrl+6 to set a mark at the beginning of the text you want to copy.
- Use arrow keys to move your cursor to the end of the section you want to copy.
- Press Alt+6 to copy the marked text to your clipboard.
- You can paste the copied text into another file by opening it in Nano and pressing Ctrl+U.
- If Alt+6 does not work on your keyboard, try Esc followed by 6 as an alternative.
Step-by-step: copying a section of text
Start by opening your file in Nano. Type nano filename.txt in your terminal and press Enter, replacing filename.txt with the actual name of your file.
Move your cursor to the first character you want to copy using the arrow keys on your keyboard. Once your cursor is in the right spot, press Ctrl+6. You will see a message at the bottom of the screen that says "Mark Set" — this tells you Nano is ready to mark text.
Now use the arrow keys to move your cursor to the end of the text you want to copy. As you move, Nano highlights the selected text in a different color so you can see what you are about to copy. When the highlight covers exactly what you need, press Alt+6 to copy it. The text is now in your clipboard.
Pasting copied text into the same file or a different one
To paste text you just copied, position your cursor where you want the text to go and press Ctrl+U. The copied text will appear at that location. You can paste the same text multiple times — it stays in your clipboard until you copy something else or close Nano.
If you want to paste into a different file, save and close your current file first by pressing Ctrl+X, then typing Y to confirm you want to save. Open the new file with nano newfilename.txt, position your cursor, and press Ctrl+U to paste.
What to do if Alt+6 does not work
Some keyboards, especially on laptops or in certain terminal programs, do not send the Alt key the way Nano expects. If Alt+6 does not copy your marked text, try pressing Esc and then 6 as two separate key presses instead. This is an alternative way to send the same command.
If that still does not work, your terminal program may be intercepting the key combination before Nano sees it. Try a different terminal process, or check whether your keyboard has an Fn key that needs to be held down to make Alt work properly.
Copying entire lines quickly
If you need to copy a whole line without marking it manually, position your cursor anywhere on that line and press Ctrl+K. This cuts the line — it removes it from the file and puts it in your clipboard. If you did not mean to remove it, press Ctrl+U right away to paste it back.
For copying without removing, mark the line with Ctrl+6, press the Down arrow once to include the entire line, then press Alt+6 to copy it. The line stays in your file and is also in your clipboard.
Saving your work after copying and pasting
Copying and pasting text inside Nano does not automatically save your file. After you finish making changes, press Ctrl+X to exit. Nano will ask whether you want to save — type Y for yes and press Enter. You can also change the filename at this point if you want to save it as something new.
If you want to save without closing Nano, that is not possible — Nano requires you to exit in order to save. However, you can press Ctrl+X, save, and then reopen the file when ready if you need to keep working.
Frequently Asked Questions
Can I copy text using my mouse in Nano?
No. Nano does not support mouse selection or clicking. You must use keyboard shortcuts to mark and copy text. If you need mouse support, you can use a different text editor like Vi or Vim, or use a graphical text editor outside the terminal.
What is the difference between Ctrl+K and Alt+6?
Ctrl+K cuts a line — it removes the text from your file and puts it in the clipboard. Alt+6 copies marked text — it leaves the original in place and puts a copy in the clipboard. Use Ctrl+K when you want to move text, and Alt+6 when you want to keep the original.
Can I copy text from Nano and paste it into another program?
Yes. When you copy text in Nano with Alt+6, it goes into your system clipboard. You can then paste it into any other program — a web browser, email, another text editor — by using that program's paste command, usually Ctrl+V.
What happens to my copied text if I close Nano?
Your copied text stays in the system clipboard even after you close Nano, so you can still paste it elsewhere. However, if you copy something new in another program, it will replace what you copied from Nano.
How do I copy multiple separate sections from the same file?
You can only have one section in the clipboard at a time. Copy the first section with Alt+6, paste it where you need it, then go back and copy the next section. If you need to keep multiple sections, paste each one into a temporary file as you go.