sh shell vi command line editing stuck in insert mode

I am using sh as my shell with the vi command line editing mode selected. I just installed the xfce desktop environment. Now I have a terrible time entering and editing commands. The command line seems to be stuck in the insert mode. Pressing Esc does not switch it to command mode. Whenever I press Esc the next character I type is "eaten" and subsequent letters appear on the line, indicating that I am still in insert mode. When I am editing a file with vi, Esc switches to command mode as expected, but not at the terminal command line. I didn't have this problem until I installed xfce. I have this problem when booting in non-graphical, console mode, and also, after issuing startx to start xfce, with the xfce terminal GUI.

Any suggestions?
 
OK, I found the problem. In my .shrc I have this line:
set -o vi

but, then farther down in my .shrc I have these lines:
# # csh like history on arrow up and down
bind ^[[A ed-search-prev-history
bind ^[[B ed-search-next-history
Those bind commands were causing some key bindings to switch back to emacs mode, at least for the "^[" sequence, which is the same as Esc. The binding for Esc gets changes to:
"^[" -> ed-sequence-lead-in

For vi editing mode the "^[" is supposed to be mapped like this:
"^[" -> vi-command-mode

Removing those extra bind commands solved the problem. I don't know why I didn't have this problem until I installed xfce, but it was probably just confusion on my part.
 
Back
Top