Sep. 22, 2009
A part from my Mac running OS X I am running quite a few Ubuntu and Debian servers and workstations. One thing that has been bugging me for quite a while is the fact that the backspace key has not been working properly in the nano editor on these systems when accessed over ssh from my OS X laptop. Instead of deleting the character immediately to the left of the cursor, it deletes the character to the right as if I was hitting the delete key.
I got some creative suggestions such as: “Well, don’t use nano use vi/emacs/pico instead”. Those are all great suggestions but I still wanted to solve the problem with nano as it’s installed on all of my systems, and I find myself using it a lot.
Doing some Googling I came up with one solution, which I wasn’t entirely happy with as it involved changing the TERM settings on the remote computer. This isn’t all bad but I wanted to try to find a solution that actually just affects nano rather than every other program that uses the TERM environment variable. For those of you that don’t consider this to be a problem you can simply place the following in your .bash_profile or equivalent file.
export TERM=xterm
By studying the /etc/nanorc I immediately found something interesting which turned out to be a better solution:
## Fix Backspace/Delete confusion problem.
set rebinddelete
In order to set this option for everyone on the system it needs to go in /etc/nanorc, however for me it’s sufficient to fix it for my own accounts. This can be done by issuing the following command:
echo "set rebinddelete" >> $HOME/.nanorc
Now, the next time you start nano the backspace should behave as backspace rather than delete. Delete still works by pressing fn+backspace as usual.