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