Download raw body.
ksh: allow editing empty line with 'v' in vi-mode
Sometimes, when I know I'm gonna write a long command, I like to use vi
mode's 'v' function to edit the command in my editor. Currently this
only works to modify a command, i.e., when the command line is not
empty, e.g.:
$ abcd^[v --> Opens editor with 'abcd'
Because of this, I've now acquired the (bad) habit of typing nonsense
before using this function, such that I can start writing the command
from scratch in the editor. The diff below allows using this function
with an empty command line:
$ ^[v --> Opens empty editor
I tried adding tests, e.g., by setting VISUAL=cat and HISTFILE=`mktemp
...`, but I couldn't get them to work. However, both the examples above,
as well as when passing a number from the command history (see fc -l),
e.g.,
$ ^[10v --> Opens 10th command in history
are still working fine.
Index: vi.c
===================================================================
RCS file: /cvs/src/bin/ksh/vi.c,v
diff -u -p -r1.70 vi.c
--- vi.c 22 May 2026 18:11:08 -0000 1.70
+++ vi.c 30 Jul 2026 18:05:10 -0000
@@ -964,8 +964,6 @@ vi_cmd(int argcnt, const char *cmd)
break;
case 'v':
- if (es->linelen == 0 && argcnt == 0)
- return -1;
if (!argcnt) {
if (modified) {
es->cbuf[es->linelen] = '\0';
ksh: allow editing empty line with 'v' in vi-mode