summaryrefslogtreecommitdiff
path: root/usr.bin/mg/mg.1
blob: d236aad005fa23490ad42a2e48686e51a6714959 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
.\"	$OpenBSD: mg.1,v 1.12 2002/02/21 04:21:17 deraadt Exp $
.\"
.Dd February 25, 2000
.Dt MG 1
.Os
.Sh NAME
.Nm mg
.Nd emacs-like text editor
.Sh SYNOPSIS
.Nm mg
.Op Ar
.Sh DESCRIPTION
.Nm
is intended to be a small, fast, and portable editor for
people who can't (or don't want to) run the real emacs for one
reason or another, or are not familiar with the
.Xr vi 1
editor.
It is compatible with emacs because there shouldn't
be any reason to learn more editor types than emacs or
.Xr vi 1 .
.Pp
Normal editing commands are very similar to Gnu Emacs.
In the following examples, ^X means control-X, and M-X means Meta-X,
where the Meta key may be either a special key on your keyboard
or the ALT key; otherwise ESC followed by the key X works as well.
.Pp
.Bl -tag -width xxxxx -compact
.It ^F
Forward character
.It ^B
Backwards character
.It ^N
Next line
.It ^P
Previous line
.It ^A
Start of line
.It ^E
End of line
.It ^D
delete current character
.It ^S
interactive search forward
.It ^R
interactive search backwards
.It ^O
Open a new line at cursor position
.It ^T
transpose characters
.It ^U
Repeat next command 4 times (can be cascaded, ie. ^u^u^f will move 16 characters forward)
.Pp
.It ^K
kill to end of line (placing into kill buffer)
.It ^Y
yank kill buffer into current location
.It ^@
set mark
.It ^W
kill region (cuts from previously set mark to current location, into kill buffer)
.It M-W
copy region (into kill buffer)
.Pp
.It ^V
Next page
.It M-V
Previous page
.It M-<
start of buffer
.It M->
end of buffer
.Pp
.It ^X^C
Quit (you will be asked if you want to save files)
.It ^X-O
Next window.
.It ^X-N
Next window.
.It ^X-P
Previous window.
.It ^X-U
Undo.
.El
.Pp
For more key bindings, type
.Dq M-x describe-bindings .
.Pp
.Nm
differs primarily in not having special modes for tasks other than
straight editing, e.g., mail and news, and in not having special modes that
support various programming languages.
It does have text justification
and auto-fill mode.
Since it is written completely in C, there is no
language in which you can write extensions.
However, you can rebind keys and change some parameters.
There are no limits to line length or format.
Command, buffer, and file name completion and listing can
be done using the spacebar and
.Ql ? ,
respectively.
.Pp
Amongst other major differences, the
.Nm
configuration files are much simpler than real emacs.
There are two configuration files,
.Pa .mg ,
and
.Pa .mg-TERM .
Here,
.Ev TERM
represents the name of you terminal type; e.g., if your terminal type
is set to
.Dq vt100 ,
.Nm
will use
.Pa .mg-vt100
as a startup file.
The terminal type startup file is used first.
See the manual for a full list of the commands that can
go in the files.
.Pp
Here's another example sequence that you may find useful.
By default,
.Dq ()
and
.Dq []
are recognized as brackets, so bracket matching can be done.
The following defines
.Dq {}
as brackets, and turns on the mode that causes
the cursor to "blink" to show you matching brackets.
.Bd -literal -offset indent
global-set-key } blink-matching-paren-hack
blink-matching-paren
set-default-mode blink
.Ed
.Pp
More complicated key mappings are also possible, though there are are some
internal limitations compared to regular emacs.  An example of how to map
control characters and sequences follows, illustrating the Gosling-like
line scrolling characters.
.Bd -literal -offset indent
global-set-key "\\^Z" scroll-one-line-up
global-set-key "\\ez" scroll-one-line-down
global-set-key "\\^_" suspend-emacs
.Ed
.Sh FILES
.Bl -tag -width ~/.mg-TERM -compact
.It Pa ~/.mg
normal startup file
.It Pa ~/.mg-TERM
terminal-specific startup file
.El
.Sh SEE ALSO
.Xr vi 1
.Sh BUGS
When you type
.Ql ?
to list possible file names, buffer names, etc.,
a help buffer is created for the possibilities.
In Gnu Emacs,
this buffer goes away the next time you type a real command.
In
.Nm mg ,
you must use "M-x 1" to get rid of it.