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