1

Every command works in Nano, except for M-6 (copy current marked text and store in cutbuffer). I've tested the alternative (M-^) as well but with no success.

Is it like this for everyone?

K7AAY
  • 17,202

1 Answers1

0

It sounds like some other program stole your Alt+6 keybinding. Look in your terminal settings to see if you can disable such shortcuts. If that doesn't work, look at your Ubuntu shortcuts for any that use Alt+6, and disable them.

Yes, there are workarounds. You can bind other keyboard shortcuts to copy instead.

Open ~/.nanorc

In there, on its own line, type

bind ^P copy all

Save it. Exit all instances of Nano.

Now you can copy in Nano (with Nano's clipboard) by typing ctrl+p instead of alt+6.

Alternatively, if you want to use the GUI's clipboard instead of Nano's, you might try this, but be sure you're in Nano 6.4 if you expect it to work with some level of confidence, because I haven't tested it in anything else:

  • sudo apt install xsel

  • open ~/.nanorc with Nano; you must edit the file with Nano (not another text editor).

  • On its own line type bind ^P "|xsel -ib" main.

  • Go between the "|, press Alt+v followed by Ctrl+t (it should output some verbatim input characters)

  • Go between the b" and press Alt+v and press enter (it should output some verbatim input characters)

  • Press Alt+v and then press Alt+u (it should output some verbatim input characters)

  • On its own line type bind ^V "xsel -ob" main.

  • Go between the "x, press Alt+v followed by Ctrl+t (it should output some verbatim input characters)

  • Go between the b" and press Alt+v and press enter (it should output some verbatim input characters)

Those two lines should end up looking something like this (but do what I said above; don't just copy and paste the following):

bind ^V "^Txsel -ob^M" main
bind ^P "^T|xsel -ib^M^[u" main
  • Save, and exit all instances of Nano.

Now, when you press Ctrl+p in Nano it'll copy with your GUI's clipboard instead of Nano's, and if you press Ctrl+v, it'll paste with your GUI's clipboard instead of Nano's (and you can use Nano's, too, for a second clipboard, if you want). You could make it do Ctrl+c instead, but you'd have to rebind other stuff if you wanted to use Nano properly (since Ctrl+c is pretty important as is).

The disadvantage of this over the first method I mentioned is that it's only for main (the main body of text); so, it won't copy/paste in the execute a command menu, the search menu, or such. However, you can use Nano's clipboard for that.