[BACK]Return to mg.1 CVS log [TXT][DIR] Up to [local] / src / usr.bin / mg

Annotation of src/usr.bin/mg/mg.1, Revision 1.32

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