Note, this question is about vi, not vim or any other clone. I work on AIX (IBMs UNIX) and the (to my knowledge standard-conforming) vi
editor.
Quite often I need to enumerate a list of values, like this:
typeset bar[1]="foo-1"
typeset bar[2]="foo-2"
typeset bar[3]="foo-3"
...
Up to now the only way to accomplish this that I know of is to manually change the number-parts in every line after copying the original line n times.
Is there a way to automate this process?
Note: I have searched and looked at How to insert repetitive text with minor difference in vim? but the suggested solution only works in vim
and also involves writing the list of what in my case are enumerations down first manually. This is exactly what I would like to avoid. Lists of arbitrary texts (like in the linked case) cannot be guessed from one another, but (ranges of) numbers can: on "1" follows "2", "3" and so on.
PS: my OS version and the version information of my vi is:
# oslevel -s
7200-05-06-2320
# lslpp -l bos.rte.edit
Fileset Level State Description
-----------------------------------------------------------
Path: /usr/lib/objrepos
bos.rte.edit 7.2.5.200 COMMITTED Editors
Path: /etc/objrepos
bos.rte.edit 7.2.5.200 COMMITTED Editors
# what /usr/bin/vi
/usr/bin/vi:
98 1.20.3.5 src/bos/usr/ccs/lib/libc/POWER/longjmp.s, libcsys, bos720 6/27/13 13:24:34
61 1.16 src/bos/usr/ccs/lib/libc/__threads_init.c, libcthrd, bos720 8/2/07 13:09:21
88 1.24 src/bos/usr/bin/ex/ex_put.c, cmdedit, bos720 4/10/06 07:47:54
50 1.13 src/bos/usr/bin/ex/ex_data.c, cmdedit, bos720 1/21/06 03:54:52
09 1.11 src/bos/usr/bin/ex/printf.c, cmdedit, bos720 8/7/00 10:14:15
69 1.17 src/bos/usr/bin/ex/ex_get.c, cmdedit, bos720 3/21/05 23:25:35
76 1.17.1.6 src/bos/usr/bin/ex/ex_v.c, cmdedit, bos720 3/11/08 01:28:00
38 1.34.2.2 src/bos/usr/bin/ex/ex_tty.c, cmdedit, bos720 3/31/04 07:01:03
40 1.28 src/bos/usr/bin/ex/ex_cmdsub.c, cmdedit, bos720 1/10/07 04:44:31
27 1.29.1.3 src/bos/usr/bin/ex/ex_temp.c, cmdedit, bos72Q, q2018_46A8 10/25/18 02:17:34
97 1.25 src/bos/usr/bin/ex/ex_vget.c, cmdedit, bos720 3/24/06 05:30:01
01 1.24 src/bos/usr/bin/ex/ex_vops.c, cmdedit, bos720 8/29/08 00:51:01
03 1.16 src/bos/usr/bin/ex/ex_vops3.c, cmdedit, bos720 3/22/05 00:02:42
00 1.15.1.4 src/bos/usr/bin/ex/ex_voper.c, cmdedit, bos720 3/22/05 01:39:20
99 1.15 src/bos/usr/bin/ex/ex_addr.c, cmdedit, bos720 10/21/05 06:32:51
98 1.26 src/bos/usr/bin/ex/ex_re.c, cmdedit, bos720 6/12/06 02:37:59
Version 3.10
18 1.35.1.4 src/bos/usr/bin/ex/ex_cmds.c, cmdedit, bos72V, v2019_46A1 10/25/19 05:52:42
80 1.27.11.1 src/bos/usr/bin/ex/ex_io.c, cmdedit, bos720 9/13/13 01:48:13
68 1.15 src/bos/usr/bin/ex/ex_unix.c, cmdedit, bos720 6/12/06 02:43:44
09 1.13 src/bos/usr/bin/ex/ex_set.c, cmdedit, bos720 1/21/06 03:54:54
99 1.33.1.9 src/bos/usr/bin/ex/ex_vmain.c, cmdedit, bos720 7/3/08 03:31:08
02 1.28 src/bos/usr/bin/ex/ex_vops2.c, cmdedit, bos720 8/7/08 00:01:05
05 1.21 src/bos/usr/bin/ex/ex_vput.c, cmdedit, bos720 3/21/05 23:17:43
84 1.13 src/bos/usr/bin/ex/ex_vadj.c, cmdedit, bos720 3/21/05 23:36:28
06 1.13 src/bos/usr/bin/ex/ex_vwind.c, cmdedit, bos720 3/21/95 17:33:51
29 1.20.1.3 src/bos/usr/bin/ex/ex_cmds2.c, cmdedit, bos720 8/2/07 07:28:08
19 1.33 src/bos/usr/bin/ex/ex_subr.c, cmdedit, bos720 3/21/05 21:50:05
67 1.11.1.44 src/bos/usr/bin/ex/ex.c, cmdedit, bos720 9/3/09 04:27:29
$ vi --version
?