Annotation of src/usr.bin/mg/mg.1, Revision 1.30
1.30 ! cloder 1: .\" $OpenBSD: mg.1,v 1.29 2006/12/29 17:07:32 reyk 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.21 henning 25: .Bl -tag -width Ds
1.16 deraadt 26: .It Ar +number
27: Go to the line specified by number (do not insert
28: a space between the "+" sign and the number).
1.20 mjc 29: If a negative number is specified, the line number counts
30: backwards from the end of the file i.e. +-1 will be the last
31: line of the file, +-2 will be second last, and so on.
1.17 vincent 32: .It Fl f Ar <mode>
33: Run the mode command for all buffers created from
34: arguments on the command line, including the
35: scratch buffer and all files.
1.30 ! cloder 36: .It Fl h
! 37: Display usage synopsis and exit.
1.21 henning 38: .It Fl n
39: Turn off backup file generation.
1.16 deraadt 40: .El
1.29 reyk 41: .Sh KEY BINDINGS
1.6 aaron 42: Normal editing commands are very similar to Gnu Emacs.
43: In the following examples, ^X means control-X, and M-X means Meta-X,
1.4 deraadt 44: where the Meta key may be either a special key on your keyboard
45: or the ALT key; otherwise ESC followed by the key X works as well.
46: .Pp
47: .Bl -tag -width xxxxx -compact
1.11 deraadt 48: .It ^F
1.25 jmc 49: Forward character.
1.11 deraadt 50: .It ^B
1.25 jmc 51: Backwards character.
1.11 deraadt 52: .It ^N
1.25 jmc 53: Next line.
1.11 deraadt 54: .It ^P
1.25 jmc 55: Previous line.
1.11 deraadt 56: .It ^A
1.25 jmc 57: Start of line.
1.11 deraadt 58: .It ^E
1.25 jmc 59: End of line.
1.11 deraadt 60: .It ^D
1.25 jmc 61: Delete current character.
1.11 deraadt 62: .It ^S
1.25 jmc 63: Interactive search forward.
1.11 deraadt 64: .It ^R
1.25 jmc 65: Interactive search backwards.
1.23 deraadt 66: .It M-%
1.25 jmc 67: Interactive search-and-replace.
1.11 deraadt 68: .It ^O
1.25 jmc 69: Open a new line at cursor position.
1.11 deraadt 70: .It ^T
1.25 jmc 71: Transpose characters.
1.11 deraadt 72: .It ^U
1.22 jmc 73: Repeat next command 4 times
1.25 jmc 74: (can be cascaded i.e. ^U^U^F will move 16 characters forward).
1.4 deraadt 75: .Pp
1.11 deraadt 76: .It ^K
1.25 jmc 77: Kill to end of line (placing into kill buffer).
1.11 deraadt 78: .It ^Y
1.25 jmc 79: Yank kill buffer into current location.
1.26 kjell 80: .It ^SPC
1.25 jmc 81: Set mark.
1.11 deraadt 82: .It ^W
1.25 jmc 83: Kill region
84: (cuts from previously set mark to current location, into kill buffer).
1.11 deraadt 85: .It M-W
1.25 jmc 86: Copy region (into kill buffer).
1.4 deraadt 87: .Pp
1.11 deraadt 88: .It ^V
1.25 jmc 89: Next page.
1.11 deraadt 90: .It M-V
1.25 jmc 91: Previous page.
1.4 deraadt 92: .It M-<
1.25 jmc 93: Start of buffer.
1.4 deraadt 94: .It M->
1.25 jmc 95: End of buffer.
1.4 deraadt 96: .Pp
1.11 deraadt 97: .It ^X^C
1.26 kjell 98: Save buffers and quit.
1.11 deraadt 99: .It ^X-O
100: Next window.
101: .It ^X-N
102: Next window.
103: .It ^X-P
104: Previous window.
1.12 deraadt 105: .It ^X-U
1.26 kjell 106: Undo.
107: .It ^_
1.12 deraadt 108: Undo.
1.4 deraadt 109: .El
110: .Pp
111: For more key bindings, type
112: .Dq M-x describe-bindings .
1.29 reyk 113: .Sh CONFIGURATION AND COMMANDS
1.10 bjc 114: Amongst other major differences, the
1.2 deraadt 115: .Nm
1.4 deraadt 116: configuration files are much simpler than real emacs.
1.7 aaron 117: There are two configuration files,
1.3 aaron 118: .Pa .mg ,
1.1 deraadt 119: and
1.3 aaron 120: .Pa .mg-TERM .
121: Here,
122: .Ev TERM
1.15 pvalchev 123: represents the name of your terminal type; e.g., if your terminal type
1.3 aaron 124: is set to
125: .Dq vt100 ,
1.2 deraadt 126: .Nm
1.1 deraadt 127: will use
1.3 aaron 128: .Pa .mg-vt100
1.6 aaron 129: as a startup file.
130: The terminal type startup file is used first.
1.28 jmc 131: The startup file format is a list of commands, one per line, as used for
132: interactive evaluation, e.g.:
133: .Bd -literal -offset indent
134: auto-fill-mode
135: set-fill-column 72
136: global-set-key "\e^x\e^f" find-file
137: .Ed
1.2 deraadt 138: .Pp
1.6 aaron 139: Here's another example sequence that you may find useful.
140: By default,
1.3 aaron 141: .Dq ()
142: and
143: .Dq []
144: are recognized as brackets, so bracket matching can be done.
145: The following defines
146: .Dq {}
147: as brackets, and turns on the mode that causes
1.1 deraadt 148: the cursor to "blink" to show you matching brackets.
1.2 deraadt 149: .Bd -literal -offset indent
150: global-set-key } blink-matching-paren-hack
151: blink-matching-paren
152: set-default-mode blink
1.11 deraadt 153: .Ed
154: .Pp
1.15 pvalchev 155: More complicated key mappings are also possible, though there are some
1.18 jmc 156: internal limitations compared to regular emacs.
157: An example of how to map control characters and sequences follows,
158: illustrating the Gosling-like line scrolling characters.
1.11 deraadt 159: .Bd -literal -offset indent
160: global-set-key "\\^Z" scroll-one-line-up
161: global-set-key "\\ez" scroll-one-line-down
162: global-set-key "\\^_" suspend-emacs
1.2 deraadt 163: .Ed
1.29 reyk 164: .Pp
165: In order to use 8-bit characters, the Meta key needs to be disabled.
166: This is required to read high bit characters like German umlauts.
167: ESC can be used instead of the Meta key \(en see the
168: .Sx KEY BINDINGS
169: section for details.
170: Execute the following command or add it to
171: .Pa .mg
172: to disable the Meta keys on startup:
173: .Bd -literal -offset indent
174: meta-key-mode
175: .Ed
1.3 aaron 176: .Sh FILES
1.8 aaron 177: .Bl -tag -width ~/.mg-TERM -compact
1.3 aaron 178: .It Pa ~/.mg
179: normal startup file
180: .It Pa ~/.mg-TERM
181: terminal-specific startup file
182: .El
183: .Sh SEE ALSO
1.2 deraadt 184: .Xr vi 1
1.29 reyk 185: .Sh CAVEATS
186: .Nm
187: differs primarily in not having special modes for tasks other than
188: straight editing, e.g., mail and news, and in not having special modes that
189: support various programming languages.
190: It does have text justification
191: and auto-fill mode.
192: Since it is written completely in C, there is no
193: language in which you can write extensions.
194: However, you can rebind keys and change some parameters.
195: There are no limits to line length or format.
196: Command, buffer, and file name completion and listing can
197: be done using the spacebar and tab keys.