On Sun, Feb 08, 2026 at 10:50:53AM +0100, Walter Alejandro Iglesias wrote:
> On Sat, Feb 07, 2026 at 05:51:02PM -0600, Tim Chase wrote:
> > On 2006-09-14 03:23, Bob Beck wrote:
> > > When I'm a sysadmin and type vi, I want vi with all it's ususal
> > > idiosyncracies so that it's basically the same no matter what system
> >
> > Idiosyncracies aside, I'd still like to see it get bug fixes, such as
> > this one that regularly bites me:
> >
> > $ yes hello | head -50 | fmt -100 > long_lines.txt
> > $ vi long_lines.txt
> > :g/^/.!fmt
> >
> > results in
> >
> > +=+=+=+=+=+=+=+
> > Illegal address: only 6 lines in the file.
> > Error: unable to retrieve line 7; 4 lines added; 2 lines deleted
> >
> > instead of re-fmt(1)ing each line individually. Another case involves
> > duplicating each line in the file:
> >
> > $ vi
> > :r !jot 100
> > :g/^/t.
> >
> > which produces:
> >
> > +=+=+=+=+=+=+=+
> > Illegal address: only 150 lines in the file.
> > Error: unable to retrieve line 151; 50 lines added
> >
> > This also ends up duplicating *every other* line, instead of duplicating
> > *every* line.
> >
> > -tkc
> >
> > PS: FWIW, the problem exists in FreeBSD's vi/nvi too:
> >
> > https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=270048
> >
> > which I reported there at the same time I reported this on bugs@
> >
> > https://marc.info/?l=openbsd-bugs&m=167830927129031&w=3
> >
> > but never heard anything on either front.
> > --
> >
>
Index: ex/ex_global.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/ex/ex_global.c,v
diff -u -p -u -p -r1.19 ex_global.c
--- ex/ex_global.c 20 Apr 2026 10:30:02 -0000 1.19
+++ ex/ex_global.c 22 Apr 2026 05:04:12 -0000
@@ -269,10 +269,10 @@ ex_g_insdel(SCR *sp, lnop_t op, recno_t
continue;
/*
- * If range greater than the line, decrement or
- * increment the range.
+ * If range is greater than or equal to the line,
+ * decrement or increment the range.
*/
- if (rp->start > lno) {
+ if (rp->start >= lno) {
if (op == LINE_DELETE) {
--rp->start;
--rp->stop;
--
Walter