xref: /minix3/external/bsd/nvi/dist/ex/ex_cmd.c (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc /*	$NetBSD: ex_cmd.c,v 1.3 2014/01/26 21:43:45 christos Exp $ */
284d9c625SLionel Sambuc /*-
384d9c625SLionel Sambuc  * Copyright (c) 1992, 1993, 1994
484d9c625SLionel Sambuc  *	The Regents of the University of California.  All rights reserved.
584d9c625SLionel Sambuc  * Copyright (c) 1992, 1993, 1994, 1995, 1996
684d9c625SLionel Sambuc  *	Keith Bostic.  All rights reserved.
784d9c625SLionel Sambuc  *
884d9c625SLionel Sambuc  * See the LICENSE file for redistribution information.
984d9c625SLionel Sambuc  */
1084d9c625SLionel Sambuc 
1184d9c625SLionel Sambuc #include "config.h"
1284d9c625SLionel Sambuc 
13*0a6a1f1dSLionel Sambuc #include <sys/cdefs.h>
14*0a6a1f1dSLionel Sambuc #if 0
1584d9c625SLionel Sambuc #ifndef lint
1684d9c625SLionel Sambuc static const char sccsid[] = "Id: ex_cmd.c,v 10.25 2001/06/10 10:23:44 skimo Exp  (Berkeley) Date: 2001/06/10 10:23:44 ";
1784d9c625SLionel Sambuc #endif /* not lint */
18*0a6a1f1dSLionel Sambuc #else
19*0a6a1f1dSLionel Sambuc __RCSID("$NetBSD: ex_cmd.c,v 1.3 2014/01/26 21:43:45 christos Exp $");
20*0a6a1f1dSLionel Sambuc #endif
2184d9c625SLionel Sambuc 
2284d9c625SLionel Sambuc #include <sys/types.h>
2384d9c625SLionel Sambuc #include <sys/queue.h>
2484d9c625SLionel Sambuc 
2584d9c625SLionel Sambuc #include <bitstring.h>
2684d9c625SLionel Sambuc #include <limits.h>
2784d9c625SLionel Sambuc #include <stdio.h>
2884d9c625SLionel Sambuc 
2984d9c625SLionel Sambuc #include "../common/common.h"
3084d9c625SLionel Sambuc 
3184d9c625SLionel Sambuc /*
3284d9c625SLionel Sambuc  * This array maps ex command names to command functions.
3384d9c625SLionel Sambuc  *
3484d9c625SLionel Sambuc  * The order in which command names are listed below is important --
3584d9c625SLionel Sambuc  * ambiguous abbreviations are resolved to be the first possible match,
3684d9c625SLionel Sambuc  * e.g. "r" means "read", not "rewind", because "read" is listed before
3784d9c625SLionel Sambuc  * "rewind".
3884d9c625SLionel Sambuc  *
3984d9c625SLionel Sambuc  * The syntax of the ex commands is unbelievably irregular, and a special
4084d9c625SLionel Sambuc  * case from beginning to end.  Each command has an associated "syntax
4184d9c625SLionel Sambuc  * script" which describes the "arguments" that are possible.  The script
4284d9c625SLionel Sambuc  * syntax is as follows:
4384d9c625SLionel Sambuc  *
4484d9c625SLionel Sambuc  *	!		-- ! flag
4584d9c625SLionel Sambuc  *	1		-- flags: [+-]*[pl#][+-]*
4684d9c625SLionel Sambuc  *	2		-- flags: [-.+^]
4784d9c625SLionel Sambuc  *	3		-- flags: [-.+^=]
4884d9c625SLionel Sambuc  *	b		-- buffer
4984d9c625SLionel Sambuc  *	c[01+a]		-- count (0-N, 1-N, signed 1-N, address offset)
5084d9c625SLionel Sambuc  *	f[N#][or]	-- file (a number or N, optional or required)
5184d9c625SLionel Sambuc  *	l		-- line
5284d9c625SLionel Sambuc  *	S		-- string with file name expansion
5384d9c625SLionel Sambuc  *	s		-- string
5484d9c625SLionel Sambuc  *	W		-- word string
5584d9c625SLionel Sambuc  *	w[N#][or]	-- word (a number or N, optional or required)
5684d9c625SLionel Sambuc  */
5784d9c625SLionel Sambuc EXCMDLIST const cmds[] = {
5884d9c625SLionel Sambuc /* C_SCROLL */
5984d9c625SLionel Sambuc 	{L("\004"),	ex_pr,		E_ADDR2,
6084d9c625SLionel Sambuc 	    "",
6184d9c625SLionel Sambuc 	    "^D",
6284d9c625SLionel Sambuc 	    "scroll lines"},
6384d9c625SLionel Sambuc /* C_BANG */
6484d9c625SLionel Sambuc 	{L("!"),		ex_bang,	E_ADDR2_NONE|E_SECURE,
6584d9c625SLionel Sambuc 	    "S",
6684d9c625SLionel Sambuc 	    "[line [,line]] ! command",
6784d9c625SLionel Sambuc 	    "filter lines through commands or run commands"},
6884d9c625SLionel Sambuc /* C_HASH */
6984d9c625SLionel Sambuc 	{L("#"),		ex_number,	E_ADDR2|E_CLRFLAG,
7084d9c625SLionel Sambuc 	    "ca1",
7184d9c625SLionel Sambuc 	    "[line [,line]] # [count] [l]",
7284d9c625SLionel Sambuc 	    "display numbered lines"},
7384d9c625SLionel Sambuc /* C_SUBAGAIN */
7484d9c625SLionel Sambuc 	{L("&"),		ex_subagain,	E_ADDR2|E_ADDR_ZERO,
7584d9c625SLionel Sambuc 	    "s",
7684d9c625SLionel Sambuc 	    "[line [,line]] & [cgr] [count] [#lp]",
7784d9c625SLionel Sambuc 	    "repeat the last subsitution"},
7884d9c625SLionel Sambuc /* C_STAR */
7984d9c625SLionel Sambuc 	{L("*"),		ex_at,		0,
8084d9c625SLionel Sambuc 	    "b",
8184d9c625SLionel Sambuc 	    "* [buffer]",
8284d9c625SLionel Sambuc 	    "execute a buffer"},
8384d9c625SLionel Sambuc /* C_SHIFTL */
8484d9c625SLionel Sambuc 	{L("<"),		ex_shiftl,	E_ADDR2|E_AUTOPRINT,
8584d9c625SLionel Sambuc 	    "ca1",
8684d9c625SLionel Sambuc 	    "[line [,line]] <[<...] [count] [flags]",
8784d9c625SLionel Sambuc 	    "shift lines left"},
8884d9c625SLionel Sambuc /* C_EQUAL */
8984d9c625SLionel Sambuc 	{L("="),		ex_equal,	E_ADDR1|E_ADDR_ZERO|E_ADDR_ZERODEF,
9084d9c625SLionel Sambuc 	    "1",
9184d9c625SLionel Sambuc 	    "[line] = [flags]",
9284d9c625SLionel Sambuc 	    "display line number"},
9384d9c625SLionel Sambuc /* C_SHIFTR */
9484d9c625SLionel Sambuc 	{L(">"),		ex_shiftr,	E_ADDR2|E_AUTOPRINT,
9584d9c625SLionel Sambuc 	    "ca1",
9684d9c625SLionel Sambuc 	    "[line [,line]] >[>...] [count] [flags]",
9784d9c625SLionel Sambuc 	    "shift lines right"},
9884d9c625SLionel Sambuc /* C_AT */
9984d9c625SLionel Sambuc 	{L("@"),		ex_at,		E_ADDR2,
10084d9c625SLionel Sambuc 	    "b",
10184d9c625SLionel Sambuc 	    "@ [buffer]",
10284d9c625SLionel Sambuc 	    "execute a buffer"},
10384d9c625SLionel Sambuc /* C_APPEND */
10484d9c625SLionel Sambuc 	{L("append"),	ex_append,	E_ADDR1|E_ADDR_ZERO|E_ADDR_ZERODEF,
10584d9c625SLionel Sambuc 	    "!",
10684d9c625SLionel Sambuc 	    "[line] a[ppend][!]",
10784d9c625SLionel Sambuc 	    "append input to a line"},
10884d9c625SLionel Sambuc /* C_ABBR */
10984d9c625SLionel Sambuc 	{L("abbreviate"), 	ex_abbr,	0,
11084d9c625SLionel Sambuc 	    "W",
11184d9c625SLionel Sambuc 	    "ab[brev] [word replace]",
11284d9c625SLionel Sambuc 	    "specify an input abbreviation"},
11384d9c625SLionel Sambuc /* C_ARGS */
11484d9c625SLionel Sambuc 	{L("args"),	ex_args,	0,
11584d9c625SLionel Sambuc 	    "",
11684d9c625SLionel Sambuc 	    "ar[gs]",
11784d9c625SLionel Sambuc 	    "display file argument list"},
11884d9c625SLionel Sambuc /* C_BG */
11984d9c625SLionel Sambuc 	{L("bg"),		ex_bg,		E_VIONLY,
12084d9c625SLionel Sambuc 	    "",
12184d9c625SLionel Sambuc 	    "bg",
12284d9c625SLionel Sambuc 	    "put a foreground screen into the background"},
12384d9c625SLionel Sambuc /* C_CHANGE */
12484d9c625SLionel Sambuc 	{L("change"),	ex_change,	E_ADDR2|E_ADDR_ZERODEF,
12584d9c625SLionel Sambuc 	    "!ca",
12684d9c625SLionel Sambuc 	    "[line [,line]] c[hange][!] [count]",
12784d9c625SLionel Sambuc 	    "change lines to input"},
12884d9c625SLionel Sambuc /* C_CD */
12984d9c625SLionel Sambuc 	{L("cd"),		ex_cd,		0,
13084d9c625SLionel Sambuc 	    "!f1o",
13184d9c625SLionel Sambuc 	    "cd[!] [directory]",
13284d9c625SLionel Sambuc 	    "change the current directory"},
13384d9c625SLionel Sambuc /* C_CHDIR */
13484d9c625SLionel Sambuc 	{L("chdir"),	ex_cd,		0,
13584d9c625SLionel Sambuc 	    "!f1o",
13684d9c625SLionel Sambuc 	    "chd[ir][!] [directory]",
13784d9c625SLionel Sambuc 	    "change the current directory"},
13884d9c625SLionel Sambuc /* C_COPY */
13984d9c625SLionel Sambuc 	{L("copy"),	ex_copy,	E_ADDR2|E_AUTOPRINT,
14084d9c625SLionel Sambuc 	    "l1",
14184d9c625SLionel Sambuc 	    "[line [,line]] co[py] line [flags]",
14284d9c625SLionel Sambuc 	    "copy lines elsewhere in the file"},
14384d9c625SLionel Sambuc /* C_CSCOPE */
14484d9c625SLionel Sambuc 	{L("cscope"),      ex_cscope,      0,
14584d9c625SLionel Sambuc 	    "!s",
14684d9c625SLionel Sambuc 	    "cs[cope] command [args]",
14784d9c625SLionel Sambuc 	    "create a set of tags using a cscope command"},
14884d9c625SLionel Sambuc /*
14984d9c625SLionel Sambuc  * !!!
15084d9c625SLionel Sambuc  * Adding new commands starting with 'd' may break the delete command code
15184d9c625SLionel Sambuc  * in ex_cmd() (the ex parser).  Read through the comments there, first.
15284d9c625SLionel Sambuc  */
15384d9c625SLionel Sambuc /* C_DELETE */
15484d9c625SLionel Sambuc 	{L("delete"),	ex_delete,	E_ADDR2|E_AUTOPRINT,
15584d9c625SLionel Sambuc 	    "bca1",
15684d9c625SLionel Sambuc 	    "[line [,line]] d[elete][flags] [buffer] [count] [flags]",
15784d9c625SLionel Sambuc 	    "delete lines from the file"},
15884d9c625SLionel Sambuc /* C_DISPLAY */
15984d9c625SLionel Sambuc 	{L("display"),	ex_display,	0,
16084d9c625SLionel Sambuc 	    "w1r",
16184d9c625SLionel Sambuc 	    "display b[uffers] | c[onnections] | s[creens] | t[ags]",
16284d9c625SLionel Sambuc 	    "display buffers, connections, screens or tags"},
16384d9c625SLionel Sambuc /* C_EDIT */
16484d9c625SLionel Sambuc 	{L("edit"),	ex_edit,	E_NEWSCREEN,
16584d9c625SLionel Sambuc 	    "f1o",
16684d9c625SLionel Sambuc 	    "[Ee][dit][!] [+cmd] [file]",
16784d9c625SLionel Sambuc 	    "begin editing another file"},
16884d9c625SLionel Sambuc /* C_EX */
16984d9c625SLionel Sambuc 	{L("ex"),		ex_edit,	E_NEWSCREEN,
17084d9c625SLionel Sambuc 	    "f1o",
17184d9c625SLionel Sambuc 	    "[Ee]x[!] [+cmd] [file]",
17284d9c625SLionel Sambuc 	    "begin editing another file"},
17384d9c625SLionel Sambuc /* C_EXUSAGE */
17484d9c625SLionel Sambuc 	{L("exusage"),	ex_usage,	0,
17584d9c625SLionel Sambuc 	    "w1o",
17684d9c625SLionel Sambuc 	    "[exu]sage [command]",
17784d9c625SLionel Sambuc 	    "display ex command usage statement"},
17884d9c625SLionel Sambuc /* C_FILE */
17984d9c625SLionel Sambuc 	{L("file"),	ex_file,	0,
18084d9c625SLionel Sambuc 	    "f1o",
18184d9c625SLionel Sambuc 	    "f[ile] [name]",
18284d9c625SLionel Sambuc 	    "display (and optionally set) file name"},
18384d9c625SLionel Sambuc /* C_FG */
18484d9c625SLionel Sambuc 	{L("fg"),		ex_fg,		E_NEWSCREEN|E_VIONLY,
18584d9c625SLionel Sambuc 	    "f1o",
18684d9c625SLionel Sambuc 	    "[Ff]g [file]",
18784d9c625SLionel Sambuc 	    "bring a backgrounded screen into the foreground"},
18884d9c625SLionel Sambuc /* C_GLOBAL */
18984d9c625SLionel Sambuc 	{L("global"),	ex_global,	E_ADDR2_ALL,
19084d9c625SLionel Sambuc 	    "!s",
19184d9c625SLionel Sambuc 	    "[line [,line]] g[lobal][!] [;/]RE[;/] [commands]",
19284d9c625SLionel Sambuc 	    "execute a global command on lines matching an RE"},
19384d9c625SLionel Sambuc /* C_HELP */
19484d9c625SLionel Sambuc 	{L("help"),	ex_help,	0,
19584d9c625SLionel Sambuc 	    "",
19684d9c625SLionel Sambuc 	    "he[lp]",
19784d9c625SLionel Sambuc 	    "display help statement"},
19884d9c625SLionel Sambuc /* C_INSERT */
19984d9c625SLionel Sambuc 	{L("insert"),	ex_insert,	E_ADDR1|E_ADDR_ZERO|E_ADDR_ZERODEF,
20084d9c625SLionel Sambuc 	    "!",
20184d9c625SLionel Sambuc 	    "[line] i[nsert][!]",
20284d9c625SLionel Sambuc 	    "insert input before a line"},
20384d9c625SLionel Sambuc /* C_JOIN */
20484d9c625SLionel Sambuc 	{L("join"),	ex_join,	E_ADDR2|E_AUTOPRINT,
20584d9c625SLionel Sambuc 	    "!ca1",
20684d9c625SLionel Sambuc 	    "[line [,line]] j[oin][!] [count] [flags]",
20784d9c625SLionel Sambuc 	    "join lines into a single line"},
20884d9c625SLionel Sambuc /* C_K */
20984d9c625SLionel Sambuc 	{L("k"),		ex_mark,	E_ADDR1,
21084d9c625SLionel Sambuc 	    "w1r",
21184d9c625SLionel Sambuc 	    "[line] k key",
21284d9c625SLionel Sambuc 	    "mark a line position"},
21384d9c625SLionel Sambuc /* C_LIST */
21484d9c625SLionel Sambuc 	{L("list"),	ex_list,	E_ADDR2|E_CLRFLAG,
21584d9c625SLionel Sambuc 	    "ca1",
21684d9c625SLionel Sambuc 	    "[line [,line]] l[ist] [count] [#]",
21784d9c625SLionel Sambuc 	    "display lines in an unambiguous form"},
21884d9c625SLionel Sambuc /* C_MOVE */
21984d9c625SLionel Sambuc 	{L("move"),	ex_move,	E_ADDR2|E_AUTOPRINT,
22084d9c625SLionel Sambuc 	    "l",
22184d9c625SLionel Sambuc 	    "[line [,line]] m[ove] line",
22284d9c625SLionel Sambuc 	    "move lines elsewhere in the file"},
22384d9c625SLionel Sambuc /* C_MARK */
22484d9c625SLionel Sambuc 	{L("mark"),	ex_mark,	E_ADDR1,
22584d9c625SLionel Sambuc 	    "w1r",
22684d9c625SLionel Sambuc 	    "[line] ma[rk] key",
22784d9c625SLionel Sambuc 	    "mark a line position"},
22884d9c625SLionel Sambuc /* C_MAP */
22984d9c625SLionel Sambuc 	{L("map"),		ex_map,		0,
23084d9c625SLionel Sambuc 	    "!W",
23184d9c625SLionel Sambuc 	    "map[!] [keys replace]",
23284d9c625SLionel Sambuc 	    "map input or commands to one or more keys"},
23384d9c625SLionel Sambuc /* C_MKEXRC */
23484d9c625SLionel Sambuc 	{L("mkexrc"),	ex_mkexrc,	0,
23584d9c625SLionel Sambuc 	    "!f1r",
23684d9c625SLionel Sambuc 	    "mkexrc[!] file",
23784d9c625SLionel Sambuc 	    "write a .exrc file"},
23884d9c625SLionel Sambuc /* C_NEXT */
23984d9c625SLionel Sambuc 	{L("next"),	ex_next,	E_NEWSCREEN,
24084d9c625SLionel Sambuc 	    "!fN",
24184d9c625SLionel Sambuc 	    "[Nn][ext][!] [+cmd] [file ...]",
24284d9c625SLionel Sambuc 	    "edit (and optionally specify) the next file"},
24384d9c625SLionel Sambuc /* C_NUMBER */
24484d9c625SLionel Sambuc 	{L("number"),	ex_number,	E_ADDR2|E_CLRFLAG,
24584d9c625SLionel Sambuc 	    "ca1",
24684d9c625SLionel Sambuc 	    "[line [,line]] nu[mber] [count] [l]",
24784d9c625SLionel Sambuc 	    "change display to number lines"},
24884d9c625SLionel Sambuc /* C_OPEN */
24984d9c625SLionel Sambuc 	{L("open"),	ex_open,	E_ADDR1,
25084d9c625SLionel Sambuc 	    "s",
25184d9c625SLionel Sambuc 	    "[line] o[pen] [/RE/] [flags]",
25284d9c625SLionel Sambuc 	    "enter \"open\" mode (not implemented)"},
25384d9c625SLionel Sambuc /* C_PRINT */
25484d9c625SLionel Sambuc 	{L("print"),	ex_pr,		E_ADDR2|E_CLRFLAG,
25584d9c625SLionel Sambuc 	    "ca1",
25684d9c625SLionel Sambuc 	    "[line [,line]] p[rint] [count] [#l]",
25784d9c625SLionel Sambuc 	    "display lines"},
25884d9c625SLionel Sambuc /* C_PERLCMD */
25984d9c625SLionel Sambuc 	{L("perl"),	ex_perl,	E_ADDR2_ALL|E_ADDR_ZERO|
26084d9c625SLionel Sambuc 					    E_ADDR_ZERODEF|E_SECURE,
26184d9c625SLionel Sambuc 	    "s",
26284d9c625SLionel Sambuc 	    "pe[rl] cmd",
26384d9c625SLionel Sambuc 	    "run the perl interpreter with the command"},
26484d9c625SLionel Sambuc /* C_PERLDOCMD */
26584d9c625SLionel Sambuc 	{L("perldo"),	ex_perl,	E_ADDR2|E_ADDR_ZERO|
26684d9c625SLionel Sambuc 					    E_ADDR_ZERODEF|E_SECURE,
26784d9c625SLionel Sambuc 	    "s",
26884d9c625SLionel Sambuc 	    "perld[o] cmd",
26984d9c625SLionel Sambuc 	    "run the perl interpreter with the command, on each line"},
27084d9c625SLionel Sambuc /* C_PRESERVE */
27184d9c625SLionel Sambuc 	{L("preserve"),	ex_preserve,	0,
27284d9c625SLionel Sambuc 	    "",
27384d9c625SLionel Sambuc 	    "pre[serve]",
27484d9c625SLionel Sambuc 	    "preserve an edit session for recovery"},
27584d9c625SLionel Sambuc /* C_PREVIOUS */
27684d9c625SLionel Sambuc 	{L("previous"),	ex_prev,	E_NEWSCREEN,
27784d9c625SLionel Sambuc 	    "!",
27884d9c625SLionel Sambuc 	    "[Pp]rev[ious][!]",
27984d9c625SLionel Sambuc 	    "edit the previous file in the file argument list"},
28084d9c625SLionel Sambuc /* C_PUT */
28184d9c625SLionel Sambuc 	{L("put"),		ex_put,
28284d9c625SLionel Sambuc 	    E_ADDR1|E_AUTOPRINT|E_ADDR_ZERO|E_ADDR_ZERODEF,
28384d9c625SLionel Sambuc 	    "b",
28484d9c625SLionel Sambuc 	    "[line] pu[t] [buffer]",
28584d9c625SLionel Sambuc 	    "append a cut buffer to the line"},
28684d9c625SLionel Sambuc /* C_QUIT */
28784d9c625SLionel Sambuc 	{L("quit"),	ex_quit,	0,
28884d9c625SLionel Sambuc 	    "!",
28984d9c625SLionel Sambuc 	    "q[uit][!]",
29084d9c625SLionel Sambuc 	    "exit ex/vi"},
29184d9c625SLionel Sambuc /* C_READ */
29284d9c625SLionel Sambuc 	{L("read"),	ex_read,	E_ADDR1|E_ADDR_ZERO|E_ADDR_ZERODEF,
29384d9c625SLionel Sambuc 	    "s",
29484d9c625SLionel Sambuc 	    "[line] r[ead] [!cmd | [file]]",
29584d9c625SLionel Sambuc 	    "append input from a command or file to the line"},
29684d9c625SLionel Sambuc /* C_RECOVER */
29784d9c625SLionel Sambuc 	{L("recover"),	ex_recover,	0,
29884d9c625SLionel Sambuc 	    "!f1r",
29984d9c625SLionel Sambuc 	    "recover[!] file",
30084d9c625SLionel Sambuc 	    "recover a saved file"},
30184d9c625SLionel Sambuc /* C_RESIZE */
30284d9c625SLionel Sambuc 	{L("resize"),	ex_resize,	E_VIONLY,
30384d9c625SLionel Sambuc 	    "c+",
30484d9c625SLionel Sambuc 	    "resize [+-]rows",
30584d9c625SLionel Sambuc 	    "grow or shrink the current screen"},
30684d9c625SLionel Sambuc /* C_REWIND */
30784d9c625SLionel Sambuc 	{L("rewind"),	ex_rew,		0,
30884d9c625SLionel Sambuc 	    "!",
30984d9c625SLionel Sambuc 	    "rew[ind][!]",
31084d9c625SLionel Sambuc 	    "re-edit all the files in the file argument list"},
31184d9c625SLionel Sambuc #ifdef GTAGS
31284d9c625SLionel Sambuc /* C_RTAG */
31384d9c625SLionel Sambuc 	{L("rtag"),	ex_rtag_push,	E_NEWSCREEN,
31484d9c625SLionel Sambuc 	    "!w1o",
31584d9c625SLionel Sambuc 	    "rta[g][!] [string]",
31684d9c625SLionel Sambuc 	    "edit the file containing the tag"},
31784d9c625SLionel Sambuc #endif
31884d9c625SLionel Sambuc /*
31984d9c625SLionel Sambuc  * !!!
32084d9c625SLionel Sambuc  * Adding new commands starting with 's' may break the substitute command code
32184d9c625SLionel Sambuc  * in ex_cmd() (the ex parser).  Read through the comments there, first.
32284d9c625SLionel Sambuc  */
32384d9c625SLionel Sambuc /* C_SUBSTITUTE */
32484d9c625SLionel Sambuc 	{L("s"),		ex_s,		E_ADDR2|E_ADDR_ZERO,
32584d9c625SLionel Sambuc 	    "s",
32684d9c625SLionel Sambuc 	    "[line [,line]] s [[/;]RE[/;]repl[/;] [cgr] [count] [#lp]]",
32784d9c625SLionel Sambuc 	    "substitute on lines matching an RE"},
32884d9c625SLionel Sambuc /* C_SCRIPT */
32984d9c625SLionel Sambuc 	{L("script"),	ex_script,	E_SECURE,
33084d9c625SLionel Sambuc 	    "!f1o",
33184d9c625SLionel Sambuc 	    "sc[ript][!] [file]",
33284d9c625SLionel Sambuc 	    "run a shell in a screen"},
33384d9c625SLionel Sambuc /* C_SET */
33484d9c625SLionel Sambuc 	{L("set"),		ex_set,		0,
33584d9c625SLionel Sambuc 	    "wN",
33684d9c625SLionel Sambuc 	    "se[t] [option[=[value]]...] [nooption ...] [option? ...] [all]",
33784d9c625SLionel Sambuc 	    "set options (use \":set all\" to see all options)"},
33884d9c625SLionel Sambuc /* C_SHELL */
33984d9c625SLionel Sambuc 	{L("shell"),	ex_shell,	E_SECURE,
34084d9c625SLionel Sambuc 	    "",
34184d9c625SLionel Sambuc 	    "sh[ell]",
34284d9c625SLionel Sambuc 	    "suspend editing and run a shell"},
34384d9c625SLionel Sambuc /* C_SOURCE */
34484d9c625SLionel Sambuc 	{L("source"),	ex_source,	0,
34584d9c625SLionel Sambuc 	    "f1r",
34684d9c625SLionel Sambuc 	    "so[urce] file",
34784d9c625SLionel Sambuc 	    "read a file of ex commands"},
34884d9c625SLionel Sambuc /* C_STOP */
34984d9c625SLionel Sambuc 	{L("stop"),	ex_stop,	E_SECURE,
35084d9c625SLionel Sambuc 	    "!",
35184d9c625SLionel Sambuc 	    "st[op][!]",
35284d9c625SLionel Sambuc 	    "suspend the edit session"},
35384d9c625SLionel Sambuc /* C_SUSPEND */
35484d9c625SLionel Sambuc 	{L("suspend"),	ex_stop,	E_SECURE,
35584d9c625SLionel Sambuc 	    "!",
35684d9c625SLionel Sambuc 	    "su[spend][!]",
35784d9c625SLionel Sambuc 	    "suspend the edit session"},
35884d9c625SLionel Sambuc /* C_T */
35984d9c625SLionel Sambuc 	{L("t"),		ex_copy,	E_ADDR2|E_AUTOPRINT,
36084d9c625SLionel Sambuc 	    "l1",
36184d9c625SLionel Sambuc 	    "[line [,line]] t line [flags]",
36284d9c625SLionel Sambuc 	    "copy lines elsewhere in the file"},
36384d9c625SLionel Sambuc /* C_TAG */
36484d9c625SLionel Sambuc 	{L("tag"),		ex_tag_push,	E_NEWSCREEN,
36584d9c625SLionel Sambuc 	    "!w1o",
36684d9c625SLionel Sambuc 	    "[Tt]a[g][!] [string]",
36784d9c625SLionel Sambuc 	    "edit the file containing the tag"},
36884d9c625SLionel Sambuc /* C_TAGNEXT */
36984d9c625SLionel Sambuc 	{L("tagnext"),	ex_tag_next,	0,
37084d9c625SLionel Sambuc 	    "!",
37184d9c625SLionel Sambuc 	    "tagn[ext][!]",
37284d9c625SLionel Sambuc 	    "move to the next tag"},
37384d9c625SLionel Sambuc /* C_TAGPOP */
37484d9c625SLionel Sambuc 	{L("tagpop"),	ex_tag_pop,	0,
37584d9c625SLionel Sambuc 	    "!w1o",
37684d9c625SLionel Sambuc 	    "tagp[op][!] [number | file]",
37784d9c625SLionel Sambuc 	    "return to the previous group of tags"},
37884d9c625SLionel Sambuc /* C_TAGPREV */
37984d9c625SLionel Sambuc 	{L("tagprev"),	ex_tag_prev,	0,
38084d9c625SLionel Sambuc 	    "!",
38184d9c625SLionel Sambuc 	    "tagpr[ev][!]",
38284d9c625SLionel Sambuc 	    "move to the previous tag"},
38384d9c625SLionel Sambuc /* C_TAGTOP */
38484d9c625SLionel Sambuc 	{L("tagtop"),	ex_tag_top,	0,
38584d9c625SLionel Sambuc 	    "!",
38684d9c625SLionel Sambuc 	    "tagt[op][!]",
38784d9c625SLionel Sambuc 	    "discard all tags"},
38884d9c625SLionel Sambuc /* C_TCLCMD */
38984d9c625SLionel Sambuc 	{L("tcl"),		ex_tcl,		E_ADDR2_ALL|E_ADDR_ZERO|
39084d9c625SLionel Sambuc 					    E_ADDR_ZERODEF|E_SECURE,
39184d9c625SLionel Sambuc 	    "s",
39284d9c625SLionel Sambuc 	    "tc[l] cmd",
39384d9c625SLionel Sambuc 	    "run the tcl interpreter with the command"},
39484d9c625SLionel Sambuc /* C_UNDO */
39584d9c625SLionel Sambuc 	{L("undo"),	ex_undo,	E_AUTOPRINT,
39684d9c625SLionel Sambuc 	    "",
39784d9c625SLionel Sambuc 	    "u[ndo]",
39884d9c625SLionel Sambuc 	    "undo the most recent change"},
39984d9c625SLionel Sambuc /* C_UNABBREVIATE */
40084d9c625SLionel Sambuc 	{L("unabbreviate"),ex_unabbr,	0,
40184d9c625SLionel Sambuc 	    "w1r",
40284d9c625SLionel Sambuc 	    "una[bbrev] word",
40384d9c625SLionel Sambuc 	    "delete an abbreviation"},
40484d9c625SLionel Sambuc /* C_UNMAP */
40584d9c625SLionel Sambuc 	{L("unmap"),	ex_unmap,	0,
40684d9c625SLionel Sambuc 	    "!w1r",
40784d9c625SLionel Sambuc 	    "unm[ap][!] word",
40884d9c625SLionel Sambuc 	    "delete an input or command map"},
40984d9c625SLionel Sambuc /* C_V */
41084d9c625SLionel Sambuc 	{L("v"),		ex_v,		E_ADDR2_ALL,
41184d9c625SLionel Sambuc 	    "s",
41284d9c625SLionel Sambuc 	    "[line [,line]] v [;/]RE[;/] [commands]",
41384d9c625SLionel Sambuc 	    "execute a global command on lines NOT matching an RE"},
41484d9c625SLionel Sambuc /* C_VERSION */
41584d9c625SLionel Sambuc 	{L("version"),	ex_version,	0,
41684d9c625SLionel Sambuc 	    "",
41784d9c625SLionel Sambuc 	    "version",
41884d9c625SLionel Sambuc 	    "display the program version information"},
41984d9c625SLionel Sambuc /* C_VISUAL_EX */
42084d9c625SLionel Sambuc 	{L("visual"),	ex_visual,	E_ADDR1|E_ADDR_ZERODEF,
42184d9c625SLionel Sambuc 	    "2c11",
42284d9c625SLionel Sambuc 	    "[line] vi[sual] [-|.|+|^] [window_size] [flags]",
42384d9c625SLionel Sambuc 	    "enter visual (vi) mode from ex mode"},
42484d9c625SLionel Sambuc /* C_VISUAL_VI */
42584d9c625SLionel Sambuc 	{L("visual"),	ex_edit,	E_NEWSCREEN,
42684d9c625SLionel Sambuc 	    "f1o",
42784d9c625SLionel Sambuc 	    "[Vv]i[sual][!] [+cmd] [file]",
42884d9c625SLionel Sambuc 	    "edit another file (from vi mode only)"},
42984d9c625SLionel Sambuc /* C_VIUSAGE */
43084d9c625SLionel Sambuc 	{L("viusage"),	ex_viusage,	0,
43184d9c625SLionel Sambuc 	    "w1o",
43284d9c625SLionel Sambuc 	    "[viu]sage [key]",
43384d9c625SLionel Sambuc 	    "display vi key usage statement"},
43484d9c625SLionel Sambuc /* C_VSPLIT */
43584d9c625SLionel Sambuc 	{L("vsplit"),	ex_edit,	E_VIONLY,
43684d9c625SLionel Sambuc 	    "f1o",
43784d9c625SLionel Sambuc 	    "vs[plit] [+cmd] [file]",
43884d9c625SLionel Sambuc 	    "split the current screen vertically"},
43984d9c625SLionel Sambuc /* C_WRITE */
44084d9c625SLionel Sambuc 	{L("write"),	ex_write,	E_ADDR2_ALL|E_ADDR_ZERODEF,
44184d9c625SLionel Sambuc 	    "!s",
44284d9c625SLionel Sambuc 	    "[line [,line]] w[rite][!] [ !cmd | [>>] [file]]",
44384d9c625SLionel Sambuc 	    "write the file"},
44484d9c625SLionel Sambuc /* C_WN */
44584d9c625SLionel Sambuc 	{L("wn"),		ex_wn,		E_ADDR2_ALL|E_ADDR_ZERODEF,
44684d9c625SLionel Sambuc 	    "!s",
44784d9c625SLionel Sambuc 	    "[line [,line]] wn[!] [>>] [file]",
44884d9c625SLionel Sambuc 	    "write the file and switch to the next file"},
44984d9c625SLionel Sambuc /* C_WQ */
45084d9c625SLionel Sambuc 	{L("wq"),		ex_wq,		E_ADDR2_ALL|E_ADDR_ZERODEF,
45184d9c625SLionel Sambuc 	    "!s",
45284d9c625SLionel Sambuc 	    "[line [,line]] wq[!] [>>] [file]",
45384d9c625SLionel Sambuc 	    "write the file and exit"},
45484d9c625SLionel Sambuc /* C_XIT */
45584d9c625SLionel Sambuc 	{L("xit"),		ex_xit,		E_ADDR2_ALL|E_ADDR_ZERODEF,
45684d9c625SLionel Sambuc 	    "!f1o",
45784d9c625SLionel Sambuc 	    "[line [,line]] x[it][!] [file]",
45884d9c625SLionel Sambuc 	    "exit"},
45984d9c625SLionel Sambuc /* C_YANK */
46084d9c625SLionel Sambuc 	{L("yank"),	ex_yank,	E_ADDR2,
46184d9c625SLionel Sambuc 	    "bca",
46284d9c625SLionel Sambuc 	    "[line [,line]] ya[nk] [buffer] [count]",
46384d9c625SLionel Sambuc 	    "copy lines to a cut buffer"},
46484d9c625SLionel Sambuc /* C_Z */
46584d9c625SLionel Sambuc 	{L("z"),		ex_z,		E_ADDR1,
46684d9c625SLionel Sambuc 	    "3c01",
46784d9c625SLionel Sambuc 	    "[line] z [-|.|+|^|=] [count] [flags]",
46884d9c625SLionel Sambuc 	    "display different screens of the file"},
46984d9c625SLionel Sambuc /* C_SUBTILDE */
47084d9c625SLionel Sambuc 	{L("~"),		ex_subtilde,	E_ADDR2|E_ADDR_ZERO,
47184d9c625SLionel Sambuc 	    "s",
47284d9c625SLionel Sambuc 	    "[line [,line]] ~ [cgr] [count] [#lp]",
47384d9c625SLionel Sambuc 	    "replace previous RE with previous replacement string,"},
47484d9c625SLionel Sambuc 	{NULL,			NULL,		0,
47584d9c625SLionel Sambuc 	     NULL,
47684d9c625SLionel Sambuc 	     NULL,
47784d9c625SLionel Sambuc 	     NULL,},
47884d9c625SLionel Sambuc };
479