BACKGROUND:

When I use vi on OpenBSD, I use stock vi (which is nvi) instead of
installing vim, because: (1), I haven't outgrown plain vanilla vi yet,
and (2), while still learning, I'm trying not to pick up vim habits
and create a dependency on vim-only features, since stock vi is on
every OpenBSD, etc. box but vim may not always be available.

PROBLEM:

vi(1) has a feature where pressing ESC while in command-line mode
(i.e. entering an ex command in command mode) will sometimes cancel
the current line of ex input, but other times will have the same
effect as if the user had pressed return.

DISCUSSION:

This is a documented behaviour. Whether ESC cancels or works like
return in command-line mode depends on whether what the user has typed
so far can already be considered a complete ex command.

>From man 1 vi:

> ⟨escape⟩
>     Execute the ex command being entered, or cancel it if it is only partial.

While this feature/bug is counter-intuitive (IMHO), I presume nvi acts
this way so as to be bug-for-bug compatible with original vi. (That's
my guess. I haven't actually confirmed this.)

Either way, if the user presses ESC to cancel a complete :x command,
the result may be unexpected.

QUESTION:

Is there any fix for this (IMHO undesirable) ESC-equals-return
behaviour in vi? Other than installing vim, which does not act this
way, at least not by default?

FLUFF:

If not, then this may be the point where I do outgrow nvi. *shrugs*
Alternatively, if there is no fix and if I continue to be unwilling to
graduate to vim, would patches to OpenBSD's stock vi be welcome? (I
sincerely doubt I'd be able to produce a patch, especially one
anywhere close to a quality acceptable to OpenBSD; I'd really struggle
with that, and for a long time too, so I'm just checking if the idea
of a vi patch for something like an option to make ESC always cancel
would already be dismissed out of hand anyway, because beware feeping
creaturism.)

Reply via email to