9

I’m using nano in iTerm2, I can mark the text using ctrl+^ but I'm not able to copy and paste the text. I know that ctrl+k can be used cut the entire line. What is the keyboard shortcut for copying only marked text in nano?

Giacomo1968
  • 53,069
  • 19
  • 162
  • 212
SG_
  • 193
  • 1
  • 1
  • 4

4 Answers4

8
  1. Set the mark to start highlighting the text : Ctrl+6 or Ctrl+Shift+6
  2. Copy the highlighted text: Option+6 or Option+Shift+6
  3. Paste the text: Ctrl+u

Note: Your meta key should mapped to the Option / Alt key (by default it would be mapped to the Esc key in case of iTerm.

On iTerm, you can do this by going to Preferences -> Profiles -> Keys and set Left option key and Right option key to Esc+

shaahiin
  • 196
  • 1
  • 5
2

Adding to @shaahiin 's answer, if you are using a Mac keyboard, try Esc + 6 instead of Option + 6 and Option + Shift + 6 instead. The meta key (indicated by M in nano) is Esc on Mac.

1

I use Option+6 shortcut to copy selected

Akceptor
  • 141
  • 4
0

I know no keystroke for it but you could cut it with CTRL-K and then paste it with CTRL-U at the same position. Afterwards you can go to the desired position and paste it again with CTRL-U. Or if you just want to copy it to another program, you can mark text an use cmd+shift+C to get it into the clipboard. To mark text you can use ctrl+^ and then you can use your arrow-keys to mark text.

I've wrote an article about this for Linux / MacOSX on my blog: https://www.ask-sheldon.com/deleting-multiple-lines-with-nano/

Vomit IT - Chunky Mess Style
  • 40,038
  • 27
  • 84
  • 117
Marcel Lange
  • 264
  • 3
  • 4
  • 1
    This doesn't appear to answer the question, and the question indicates that SG_ already knows how to cut and paste entire lines and how to mark text. – 8bittree Sep 25 '15 at 18:24
  • Why? I told him how to work around the problem! Do you see a CTRL-U in his question? Or do you have a better answer? – Marcel Lange Sep 26 '15 at 10:25