NetBSD Problem Report #60010
From www@netbsd.org Mon Feb 16 09:56:17 2026
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256
client-signature RSA-PSS (2048 bits) client-digest SHA256)
(Client CN "mail.netbsd.org", Issuer "R13" (verified OK))
by mollari.NetBSD.org (Postfix) with ESMTPS id 5B7021A9239
for <gnats-bugs@gnats.NetBSD.org>; Mon, 16 Feb 2026 09:56:17 +0000 (UTC)
Message-Id: <20260216095616.3A6181A923C@mollari.NetBSD.org>
Date: Mon, 16 Feb 2026 09:56:16 +0000 (UTC)
From: thorpej@me.com
Reply-To: thorpej@me.com
To: gnats-bugs@NetBSD.org
Subject: "expandtab" behaves counter-intuitively (and different from vim)
X-Send-Pr-Version: www-1.0
X-From4GNATS: "thorpej@me.com via gnats" <gnats-admin@NetBSD.org>
>Number: 60010
>Category: bin
>Synopsis: "expandtab" behaves counter-intuitively (and different from vim)
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: bin-bug-people
>State: open
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Mon Feb 16 10:00:01 +0000 2026
>Last-Modified: Tue Feb 17 06:45:00 +0000 2026
>Originator: Jason Thorpe
>Release: NetBSD 10.99.10 (but 11 is the same)
>Organization:
Formatting Fanatics Anonymous
>Environment:
NetBSD the-ripe-vessel 10.99.10 NetBSD 10.99.10 (GENERIC) #68: Fri Nov 17 14:40:27 PST 2023 thorpej@the-ripe-vessel:/space/src/sys/arch/amd64/compile/GENERIC amd64
>Description:
"expandtab" is documented as:
expandtab, et [off]
Prevent the use of <tab> characters in leading whitespace when
shifting text, autoindenting, indenting with <control-T>, or
outdenting with <control-D>.
This is different behavior from vim, for which <control-I> (i.e. <tab>) also applies. As you know, vim is shipped as the "vi" on a pretty large number of systems, thus making NetBSD's behavior in this regard an outlier.
I think the documented behavior is counter-intuitive and "correct" only in the sense that it matches the documentation. It leads to inconsistent indenting within a source file because <tab> is an easy (and natural) character to type, whereas <control-T> is not. Furthermore, the setting is called "expandtab" and the key on the keyboard labeled "TAB" does not get the "expand" treatment.
>How-To-Repeat:
Edit a file. Set "ts=2", "et", and "ai". Create a line with a leading <tab> character and some text. Hit return and let the editor auto-indent the next line and type some additional text. Now, set "ts=8" and observe.
oink
snort
oink
snort
>Fix:
Yes please!
>Audit-Trail:
From: Kimmo Suominen <kim@netbsd.org>
To: gnats-bugs@netbsd.org
Cc:
Subject: Re: bin/60010: "expandtab" behaves counter-intuitively (and
different from vim)
Date: Mon, 16 Feb 2026 12:54:46 +0200
Hi,
I don't think this is a bug. Indenting is done with Control-T, not
Control-I (TAB). Inputting a TAB is done with the TAB key or with
Control-I. It would be counter-intuitive if TAB would produce spaces
instead.
I think vim has gotten this wrong (among other things).
However, it is easy to install vim from pkgsrc, and pkg_alternatives
can be used to make it available as vi (as one possible approach).
Kind regards,
+ Kimmo
From: Kimmo Suominen <kim@netbsd.org>
To: gnats-bugs@netbsd.org
Cc:
Subject: Re: bin/60010: "expandtab" behaves counter-intuitively (and
different from vim)
Date: Mon, 16 Feb 2026 13:03:05 +0200
Or possibly
map! ^I ^T
in your ~/.exrc might solve it (but can also be annoying).
Cheers,
+ Kimmo
From: Jason Thorpe <thorpej@me.com>
To: gnats-bugs@netbsd.org
Cc: gnats-admin@netbsd.org,
netbsd-bugs@netbsd.org
Subject: Re: bin/60010: "expandtab" behaves counter-intuitively (and different
from vim)
Date: Mon, 16 Feb 2026 08:03:32 -0500
> I don't think this is a bug. Indenting is done with Control-T, not
> Control-I (TAB). Inputting a TAB is done with the TAB key or with
> Control-I. It would be counter-intuitive if TAB would produce spaces
> instead.
>=20
> I think vim has gotten this wrong (among other things).
It just seems a ridiculous from a UI perspective. Manual indenting is =
done *a lot*, and Control-T is simply not a convenient key combination =
(no matter where you keep your Control key) where as the Tab key is =
*right there* and I=E2=80=99d venture to guess that practically everyone =
instinctively hits Tab (unless you=E2=80=99re an emacs user, in which =
case you=E2=80=99re a lost cause :-). (The subtext here is: =E2=80=9CIf =
I wanted to torture myself with bucky bits, I=E2=80=99d use emacs!=E2=80=9D=
). Having consistency in formatting should not require setting both ts =
and sw and overcoming decades of muscle memory to hit an awkward key =
combination.
-- thorpej
From: Valery Ushakov <uwe@stderr.spb.ru>
To: gnats-bugs@netbsd.org
Cc:
Subject: Re: bin/60010: "expandtab" behaves counter-intuitively (and
different from vim)
Date: Mon, 16 Feb 2026 18:54:34 +0300
On Mon, Feb 16, 2026 at 13:05:01 +0000, Jason Thorpe via gnats wrote:
> Having consistency in formatting should not require setting both ts
> and sw and overcoming decades of muscle memory to hit an awkward key
> combination.
If your muscle memory is that of vim, then use vim. Consider that
other people may have different muscle memory and you are proposing to
ruin theirs.
Full disclosure: I'm an emacs user. Bite me.
-uwe
From: Jason Thorpe <thorpej@me.com>
To: gnats-bugs@netbsd.org
Cc: gnats-admin@netbsd.org,
netbsd-bugs@netbsd.org
Subject: Re: bin/60010: "expandtab" behaves counter-intuitively (and different
from vim)
Date: Mon, 16 Feb 2026 11:20:34 -0500
> On Feb 16, 2026, at 10:55=E2=80=AFAM, Valery Ushakov via gnats =
<gnats-admin@NetBSD.org> wrote:
>=20
> If your muscle memory is that of vim, then use vim. Consider that
> other people may have different muscle memory and you are proposing to
> ruin theirs.
Well, this really only comes into play when you=E2=80=99re working on a =
code base that doesn=E2=80=99t conform to KNF (were the Tab vs Control-T =
distinction is pretty much meaningless). *This* is where my muscle =
memory comes from, 30 years of writing/editing KNF-conforming code with =
the default ts=3D8, where hitting the Tab key absolutely does the right =
thing and Control-T simply isn=E2=80=99t necessary.
Like, it=E2=80=99s been so =E2=80=9Cout of sight out of mind=E2=80=9D =
that I had completely forgotten about the sw property because with =
KNF-conforming code you simply don=E2=80=99t have to care.
The other thing that irks me about the current situation: the setting in =
question is called =E2=80=9Cexpandtab=E2=80=9D, not =E2=80=9Cexpandcontrol=
t=E2=80=9D to =E2=80=9Cexpandtoshiftwidth=E2=80=9D.
The issue only came up for me recently because I=E2=80=99ve been working =
on a code base that is in a sort of hybrid GNU/KNF style, which uses =
2-space tabs and all indents are expanded to spaces. My assumption is =
that the original author wrote it using emacs, although none of the =
usual emacs formatting markup is present in any of the files.
In any case, I would be happy enough with something I could put into my =
~/.exrc (which for the last 30 years has read "set ai nomagic sm=E2=80=9D)=
to enable what I would term =E2=80=9Crational expandtab behavior=E2=80=9D=
. That way no one else=E2=80=99s muscle memory would be disturbed.
-- thorpej
From: RVP <rvp@SDF.ORG>
To: gnats-bugs@netbsd.org
Cc:
Subject: Re: bin/60010: "expandtab" behaves counter-intuitively (and different
from vim)
Date: Tue, 17 Feb 2026 06:40:20 +0000 (UTC)
This OK? (`:set compat' is on so that I don't get yelled at...too much.)
-RVP
---START patch---
diff -urN external/bsd/nvi.orig/dist/common/options.c external/bsd/nvi/dist/common/options.c
--- external/bsd/nvi.orig/dist/common/options.c 2019-10-04 09:01:59.000000000 +0000
+++ external/bsd/nvi/dist/common/options.c 2026-02-17 05:22:52.312044929 +0000
@@ -80,6 +80,8 @@
{L("combined"), NULL, OPT_0BOOL, OPT_NOSET|OPT_WC},
/* O_COMMENT 4.4BSD */
{L("comment"), NULL, OPT_0BOOL, 0},
+/* O_COMPAT NetBSD 12.0 */
+ {L("compat"), NULL, OPT_1BOOL, 0},
/* O_TMP_DIRECTORY 4BSD */
{L("directory"), NULL, OPT_STR, 0},
/* O_EDCOMPATIBLE 4BSD */
@@ -282,6 +284,7 @@
{L("aw"), O_AUTOWRITE}, /* 4BSD */
{L("bf"), O_BEAUTIFY}, /* 4BSD */
{L("co"), O_COLUMNS}, /* 4.4BSD */
+ {L("cp"), O_COMPAT}, /* NetBSD 12.0 */
{L("dir"), O_TMP_DIRECTORY}, /* 4BSD */
{L("eb"), O_ERRORBELLS}, /* 4BSD */
{L("ed"), O_EDCOMPATIBLE}, /* 4BSD */
diff -urN external/bsd/nvi.orig/dist/docs/vi.man/vi.1 external/bsd/nvi/dist/docs/vi.man/vi.1
--- external/bsd/nvi.orig/dist/docs/vi.man/vi.1 2025-04-08 04:00:22.996066228 +0000
+++ external/bsd/nvi/dist/docs/vi.man/vi.1 2026-02-17 05:55:07.869829433 +0000
@@ -1087,6 +1087,22 @@
only.
Skip leading comments in shell, C and C++ language files.
.TP
+.B "compat, cp [on]"
+.I \&Vi
+only.
+Toggle compatibility with traditional
+.I \&Vi
+behaviour.
+Only effects the behaviour of
+.BR "autoindent"
+and
+.BR "expandtab",
+where setting
+.BR "nocompat"
+will expand
+.I all
+tabs to spaces; ie. not only those at the beginning of lines.
+.TP
.B "directory, dir [environment variable TMPDIR, or /tmp]"
The directory where temporary files are created.
.TP
diff -urN external/bsd/nvi.orig/dist/motif_l/m_options.c external/bsd/nvi/dist/motif_l/m_options.c
--- external/bsd/nvi.orig/dist/motif_l/m_options.c 2014-01-26 21:43:45.000000000 +0000
+++ external/bsd/nvi/dist/motif_l/m_options.c 2026-02-17 05:14:23.065699319 +0000
@@ -100,6 +100,7 @@
{ optString, "path", },
{ optTerminator, },
}, general[] = {
+ { optToggle, "compat", },
{ optToggle, "exrc", },
{ optToggle, "lisp", },
{ optToggle, "modeline", },
diff -urN external/bsd/nvi.orig/dist/vi/v_txt.c external/bsd/nvi/dist/vi/v_txt.c
--- external/bsd/nvi.orig/dist/vi/v_txt.c 2020-07-07 10:58:43.000000000 +0000
+++ external/bsd/nvi/dist/vi/v_txt.c 2026-02-17 05:25:13.816201508 +0000
@@ -1201,6 +1201,10 @@
if (FL_ISSET(is_flags, IS_RUNNING))
FL_SET(is_flags, IS_RESTART);
break;
+ case K_TAB:
+ if (O_ISSET(sp, O_COMPAT))
+ goto ins_ch;
+ /* FALLTHROUGH */
case K_CNTRLT: /* Add autoindent characters. */
if (!LF_ISSET(TXT_CNTRLT))
goto ins_ch;
---END patch---
(Contact us)
$NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2026
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.