NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: bin/60010: "expandtab" behaves counter-intuitively (and different from vim)



The following reply was made to PR bin/60010; it has been noted by GNATS.

From: RVP <rvp%SDF.ORG@localhost>
To: gnats-bugs%netbsd.org@localhost
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---
 


Home | Main Index | Thread Index | Old Index