I'm using the default ksh
on OpenBSD 6.2 (based on pdksh
) with Vi command line editing mode enabled.
I'm trying to get the arrow keys to work properly as a complement to h, l, j and k (as I'm on a Dvorak keyboard). As far as I can tell, they don't work at all. It does not matter whether I'm in "input" or "command" mode.
The current key bindings includes:
^[[A = up-history
^[[B = down-history
^[[C = forward-char
^[[D = backward-char
These are also the character sequenced produced by my arrow keys if I use Ctrl+VArrow key.
The arrow keys works as expected in Emacs command line editing mode, but as a long time Vi user, I feel somewhat crippled when using it.
My feeling is that the Escape that is sent by the arrow key is interpreted as if I pressed Esc… I get the equivalent behaviour by manually typing e.g. Esc[A as when I press Up-arrow (places me in command mode and then in insert mode at the end of the line).
Question: Has anyone been able to get the arrow keys to work intuitively in Vi-mode in OpenBSD's ksh
?
Best Answer
I did a quick foray into
/usr/src/bin/ksh
on my OpenBSD system, seeing as I had the actual sources checked out anyway. I had a cursory glance atc_ksh.c
,emacs.c
andvi.c
and it looks as if the Vi mode was retrofitted intopdksh
fromnsh
at some point (around 1989/1990). The exact words used areThe
bind
-able functions all live inemacs.c
, as does thex_bind()
function which gets called by thebind
builtin, whilevi.c
seems to have its own implementation of some of them under different names that are not called fromx_bind()
.Therefore I think I can conclude that the
bind
builtin is a no-op in Vi-mode in this particular shell.UPDATE (2018-02-04): After reporting this to the
openbsd-misc
list, it was confirmed thatbind
does indeed not do anything in Vi command line editing mode. A patch will go in to modify theksh
manual on OpenBSD so that this is mentioned: