Is there a way to edit the keyboard shortcuts in Nano?
I would like to change Move to next word from Right (Ctrl + Space) and Left (Alt + Space),
to Alt + ← or →.
According to this thread on AskUbuntu, one should be able to edit /etc/nanorc
. However, on my OS X computer, that file is empty except for this line:
set nowrap
Assuming that this is the only file there is, how could I override the keyboard settings here?
Best Answer
If you install a more up-to-date version of nano, it has improved keyboard navigation. In nano 2.7, the move word shortcut is
ctrl+left/right
. So you might not even need to do keybindings if you are satisfied withctrl
instead ofalt
.brew install nano
If you really want
alt
, then keep reading.If using Mac Terminal, you will need to enable the
Use Option as Meta key
setting. Otherwise thealt
key won't work./etc/nanorc
might be ignored, depending on the flags when yournano
was compiled. You can use~/.nanorc
instead, that will work for sure.Add these lines to
~/.nanorc
. (It seems thatnanorc
does not allow left/right arrows for keybindings, so I chose,
and.
since they are the same keys as<
and>
.Now
alt+,
andalt+.
will move to prev/next words.You can find the full list of commands here: https://www.nano-editor.org/dist/v2.7/nanorc.5.html#REBINDING%20KEYS . (You may want to find the exact version of your
nano
if not v2.7).