John Weighs in on Linux Backspace/Delete Topic

If you google "Linux Backspace Delete" you'll be treated to an array of articles that are exceedingly comprehensive and well written explaining how

  1. The whole topic of keyboard handling in linux is very complex.
  2. How backspace and delete are particularly problematic.

The complexity goes all the way back to the early days of computing, and how VT100 terminals were implemented. You would think that here in 2012 we would no longer be saddled with issues related to trying to emulate these historical relics but that, sadly, is not the case.  

The layers of processing that go on between a key being pressed on your keyboard and a character appearing on your screen are way more than you might think. There are scancodes, keycodes, and keysyms. There are termcap and terminfo databases, there is X which has a say in the whole matter, and there are the individual applications themselves. And then there are the terminals (xterm, gnome-terminal, KDE console, etc.). 

To make a long story short I was able to determine that for me running Fedora Core 16, the ambiguous statement "Backspace and Delete aren't working" was, in reality, purely an xterm problem. I'm partial to xterm, and use it exclusively. My problems really began and ended with how these keys behaved in an xterm environment.

I realized that while in vi (not my usual editor, just something I use in a pinch) or in less, that backspaces and deletes were generating "^?" on the screen and therefore not doing what they were meant to do. But gnome-terminal was fine, as was Xemacs as were basically all my other applications.

It turned out that by inserting 

                             :if &term == "xterm"
                             :  set t_kb=^V
                             :  fixdel
                             :endif

into .vimrc (I have vi aliased to vim) the vi problem could be made to go away.

However, less was still misbehaving (therefore so were the man pages that use less).  But by going into my .Xdefaults and making the following change


!xterm*ttyModes:         intr ^c erase ^h susp ^@ dsusp ^@ kill ^u eof ^d
 xterm*ttyModes:         intr ^c erase ^? susp ^@ dsusp ^@ kill ^u eof ^d

i.e. change "erase ^h" to "erase ^?" and now all is well.

I'm not altogether sure why I had that original line in my .Xdefaults, and don't understand why for suspend works with ^z even though it's configured to work with ^@, nevertheless, things are working now, so I won't change things further unless another problem arises.

Addendum: Above seemed to work for a while but then inexplicably stopped working and the old familiar ^? characters started showing up in xterm. So reverted back to the first line in ttyModes (erase ^h) but set backarrowKey to true so:



                   xterm*backarrowKey:  true
                   xterm*ttyModes:          intr ^c erase ^h susp ^@ dsusp ^@ kill ^u eof ^d

and now things are working again. You can confirm the status of this variable by left-clicking your xterm while holding down control key.  The pop menu key will display 


                   Backarrow Key (BS/DEL) 


and it will have a checkbox next to it if this variable is set to TRUE.


Some folks say that this will create "other problems" but I have yet to see any.

Comments

Popular posts from this blog

Hit failing alternator with a hammer to confirm diagnosis of failing alternator due to bad brushes

alternatives --install gets stuck: failed to read link: No such file or directory

Using SSH, SOCKS, tsocks, and proxy settings to create a simultaneous "dual use" work/home computer