This is consistent with vim's expandtab behavior.
From nvi2 (Craig Leres). OK tb@
-.\" $OpenBSD: vi.1,v 1.80 2022/03/31 17:27:28 naddy Exp $
+.\" $OpenBSD: vi.1,v 1.81 2022/04/22 15:48:29 millert Exp $
.\"
.\" Copyright (c) 1994
.\" The Regents of the University of California. All rights reserved.
.\"
.\" @(#)vi.1 8.51 (Berkeley) 10/10/96
.\"
-.Dd $Mdocdate: March 31 2022 $
+.Dd $Mdocdate: April 22 2022 $
.Dt VI 1
.Os
.Sh NAME
when inserting, replacing or shifting text, autoindenting,
indenting with
.Aq Ic control-T ,
-or outdenting with
-.Aq Ic control-D .
+outdenting with
+.Aq Ic control-D ,
+or
+when filtering lines with the
+.Cm !\&
+command.
.It Cm exrc , ex Bq off
Read the startup files in the local directory.
.It Cm extended Bq off
-/* $OpenBSD: ex_bang.c,v 1.11 2017/04/18 01:45:35 deraadt Exp $ */
+/* $OpenBSD: ex_bang.c,v 1.12 2022/04/22 15:48:29 millert Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
if (!F_ISSET(sp, SC_VI) && !F_ISSET(sp, SC_EX_SILENT))
(void)ex_puts(sp, "!\n");
+ /* Apply expandtab to the new text */
+ if (O_ISSET(sp, O_EXPANDTAB))
+ ex_retab(sp, cmdp);
+
/*
* XXX
* The ! commands never return an error, so that autoprint always
-/* $OpenBSD: ex_shift.c,v 1.9 2020/04/30 10:40:21 millert Exp $ */
+/* $OpenBSD: ex_shift.c,v 1.10 2022/04/22 15:48:29 millert Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
#include "../common/common.h"
-enum which {LEFT, RIGHT};
+enum which {RETAB, LEFT, RIGHT};
static int shift(SCR *, EXCMD *, enum which);
/*
return (shift(sp, cmdp, RIGHT));
}
+/*
+ * ex_retab -- Expand tabs (if enabled)
+ *
+ *
+ * PUBLIC: int ex_retab(SCR *, EXCMD *);
+ */
+int
+ex_retab(SCR *sp, EXCMD *cmdp)
+{
+ return (shift(sp, cmdp, RETAB));
+}
+
/*
* shift --
* Ex shift support.
break;
/* Calculate the new indent amount. */
- if (rl == RIGHT)
+ if (rl == RETAB)
+ newcol = oldcol;
+ else if (rl == RIGHT)
newcol = oldcol + sw;
else {
newcol = oldcol < sw ? 0 : oldcol - sw;
-/* $OpenBSD: ex_extern.h,v 1.16 2016/05/27 09:18:12 martijn Exp $ */
+/* $OpenBSD: ex_extern.h,v 1.17 2022/04/22 15:48:29 millert Exp $ */
int ex(SCR **);
int ex_cmd(SCR *);
int ex_shell(SCR *, EXCMD *);
int ex_exec_proc(SCR *, EXCMD *, char *, const char *, int);
int proc_wait(SCR *, pid_t, const char *, int, int);
+int ex_retab(SCR *, EXCMD *);
int ex_shiftl(SCR *, EXCMD *);
int ex_shiftr(SCR *, EXCMD *);
int ex_source(SCR *, EXCMD *);