[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.132

1.132   ! op          1: .\"    $OpenBSD: mg.1,v 1.131 2023/04/25 08:37:24 op Exp $
1.34      kjell       2: .\" This file is in the public domain.
1.9       niklas      3: .\"
1.132   ! op          4: .Dd $Mdocdate: April 25 2023 $
1.2       deraadt     5: .Dt MG 1
                      6: .Os
                      7: .Sh NAME
                      8: .Nm mg
                      9: .Nd emacs-like text editor
                     10: .Sh SYNOPSIS
                     11: .Nm mg
1.98      lum        12: .Op Fl nR
1.121     lum        13: .Op Fl b Ar file
1.36      sobrado    14: .Op Fl f Ar mode
1.119     lum        15: .Op Fl u Ar file
1.36      sobrado    16: .Op + Ns Ar number
                     17: .Op Ar
1.2       deraadt    18: .Sh DESCRIPTION
                     19: .Nm
1.3       aaron      20: is intended to be a small, fast, and portable editor for
1.33      kjell      21: people who can't (or don't want to) run emacs for one
1.2       deraadt    22: reason or another, or are not familiar with the
                     23: .Xr vi 1
1.6       aaron      24: editor.
                     25: It is compatible with emacs because there shouldn't
1.2       deraadt    26: be any reason to learn more editor types than emacs or
                     27: .Xr vi 1 .
1.16      deraadt    28: .Pp
1.17      vincent    29: The options are as follows:
1.21      henning    30: .Bl -tag -width Ds
1.36      sobrado    31: .It + Ns Ar number
1.16      deraadt    32: Go to the line specified by number (do not insert
1.33      kjell      33: a space between the
                     34: .Sq +
                     35: sign and the number).
1.20      mjc        36: If a negative number is specified, the line number counts
                     37: backwards from the end of the file i.e. +-1 will be the last
                     38: line of the file, +-2 will be second last, and so on.
1.121     lum        39: .It Fl b Ar file
                     40: Turn on batch mode and execute the
                     41: .Nm
                     42: commands found in the specified
                     43: .Ar file
                     44: and then terminate.
1.36      sobrado    45: .It Fl f Ar mode
1.132   ! op         46: Run the
        !            47: .Ar mode
        !            48: command for all buffers created from
1.17      vincent    49: arguments on the command line, including the
                     50: scratch buffer and all files.
1.120     lum        51: .It Fl n
                     52: Turn off backup file generation.
                     53: .It Fl R
                     54: Files specified on the command line will be opened read-only.
1.119     lum        55: .It Fl u Ar file
                     56: Use
                     57: .Ar file
                     58: as the startup file, instead of the default
                     59: .Pa ~/.mg .
1.16      deraadt    60: .El
1.33      kjell      61: .Sh WINDOWS AND BUFFERS
                     62: When a file is loaded into
                     63: .Nm ,
                     64: it is stored in a
                     65: .Em buffer .
                     66: This buffer may be displayed on the screen in more than one window.
                     67: At present, windows may only be split horizontally, so each window is
                     68: delineated by a modeline at the bottom.
                     69: If changes are made to a buffer, it will be reflected in all open windows.
1.70      florian    70: .Pp
                     71: If a file is changed outside
                     72: .Nm
                     73: and its buffer is about to be changed,
                     74: .Nm
                     75: prompts if the change should go ahead (y), not go ahead (n) or if the buffer
                     76: should be reverted (r) to the latest file on disk.
1.43      kjell      77: .Pp
                     78: If a buffer name begins and ends with an asterisk, the buffer is considered
1.44      jmc        79: throwaway; i.e. the user will not be prompted to save changes when
1.43      kjell      80: the buffer is killed.
1.33      kjell      81: .Sh POINT AND MARK
                     82: The current cursor location in
                     83: .Nm
                     84: is called the
1.39      jmc        85: .Em point
1.37      kjell      86: (or
                     87: .Em dot ) .
1.33      kjell      88: It is possible to define a window-specific region of text by setting a second
                     89: location, called the
                     90: .Em mark .
                     91: The
                     92: .Em region
                     93: is the text between point and mark inclusive.
                     94: Deleting the character at the mark position leaves
                     95: the mark at the point of deletion.
                     96: .Pp
                     97: Note: The point and mark are window-specific in
                     98: .Nm ,
                     99: not buffer-specific, as in other emacs flavours.
1.64      lum       100: .Sh BACKUP FILES
1.65      jmc       101: Backup files have a
                    102: .Sq ~
                    103: character appended to the file name and
1.64      lum       104: are created in the current working directory by default.
                    105: Whether to create backup files or not can be toggled with the
1.90      jmc       106: make-backup-files command.
1.64      lum       107: The backup file location can either be in the current
1.65      jmc       108: working directory, or all backups can be moved to a
                    109: .Pa ~/.mg.d
                    110: directory where files retain their path name to retain uniqueness.
1.64      lum       111: Use the backup-to-home-directory to alternate between these two locations.
1.105     tedu      112: Further, if any application creates backup files in
                    113: .Pa /tmp ,
1.64      lum       114: these can be left with the leave-tmpdir-backups command.
1.56      lum       115: .Sh TAGS
                    116: .Nm
1.57      lum       117: supports tag files created by
1.56      lum       118: .Xr ctags 1 ,
1.57      lum       119: allowing the user to quickly locate various object definitions.
                    120: Note though that emacs uses etags, not ctags.
1.61      lum       121: .Sh CSCOPE
                    122: .Nm
                    123: supports navigating source code using cscope.
                    124: However,
                    125: .Nm
                    126: requires cscope and cscope-indexer executables to be present in
                    127: .Ev PATH
                    128: for it to work.
1.33      kjell     129: .Sh DEFAULT KEY BINDINGS
1.53      lum       130: Normal editing commands are very similar to GNU Emacs.
1.47      sobrado   131: In the following examples, C-x means Control-x, and M-x means Meta-x,
1.54      lum       132: where the Meta key may be either a special key on the keyboard
1.4       deraadt   133: or the ALT key; otherwise ESC followed by the key X works as well.
                    134: .Pp
1.66      jmc       135: .Bl -tag -width xxxxxxxxxxxx -offset indent -compact
1.37      kjell     136: .It C-SPC
                    137: set-mark-command
                    138: .It C-a
                    139: beginning-of-line
                    140: .It C-b
                    141: backward-char
1.61      lum       142: .It C-c s c
                    143: cscope-find-functions-calling-this-function
                    144: .It C-c s d
                    145: cscope-find-global-definition
                    146: .It C-c s e
                    147: cscope-find-egrep-pattern
                    148: .It C-c s f
                    149: cscope-find-this-file
                    150: .It C-c s i
                    151: cscope-find-files-including-file
                    152: .It C-c s n
                    153: cscope-next-symbol
                    154: .It C-c s p
                    155: cscope-prev-symbol
                    156: .It C-c s s
                    157: cscope-find-this-symbol
                    158: .It C-c s t
                    159: cscope-find-this-text-string
1.37      kjell     160: .It C-d
                    161: delete-char
                    162: .It C-e
                    163: end-of-line
                    164: .It C-f
                    165: forward-char
                    166: .It C-g
                    167: keyboard-quit
                    168: .It C-h C-h
                    169: help-help
                    170: .It C-h a
                    171: apropos
                    172: .It C-h b
                    173: describe-bindings
                    174: .It C-h c
                    175: describe-key-briefly
                    176: .It C-j
                    177: newline-and-indent
                    178: .It C-k
                    179: kill-line
                    180: .It C-l
                    181: recenter
                    182: .It RET
                    183: newline
                    184: .It C-n
                    185: next-line
                    186: .It C-o
                    187: open-line
                    188: .It C-p
                    189: previous-line
                    190: .It C-q
                    191: quoted-insert
                    192: .It C-r
                    193: isearch-backward
                    194: .It C-s
                    195: isearch-forward
                    196: .It C-t
                    197: transpose-chars
                    198: .It C-u
                    199: universal-argument
                    200: .It C-v
                    201: scroll-up
                    202: .It C-w
                    203: kill-region
                    204: .It C-x C-b
                    205: list-buffers
                    206: .It C-x C-c
                    207: save-buffers-kill-emacs
                    208: .It C-x C-f
                    209: find-file
1.123     lum       210: .It C-x C-j
                    211: dired-jump
1.37      kjell     212: .It C-x C-g
                    213: keyboard-quit
                    214: .It C-x C-l
                    215: downcase-region
                    216: .It C-x C-o
                    217: delete-blank-lines
                    218: .It C-x C-q
                    219: toggle-read-only
                    220: .It C-x C-r
                    221: find-file-read-only
                    222: .It C-x C-s
                    223: save-buffer
                    224: .It C-x C-u
                    225: upcase-region
                    226: .It C-x C-v
                    227: find-alternate-file
                    228: .It C-x C-w
                    229: write-file
                    230: .It C-x C-x
                    231: exchange-point-and-mark
                    232: .It C-x (
                    233: start-kbd-macro
1.45      nicm      234: .It C-x \&)
1.37      kjell     235: end-kbd-macro
                    236: .It C-x 0
                    237: delete-window
                    238: .It C-x 1
                    239: delete-other-windows
                    240: .It C-x 2
                    241: split-window-vertically
                    242: .It C-x 4 C-f
                    243: find-file-other-window
                    244: .It C-x 4 C-g
                    245: keyboard-quit
                    246: .It C-x 4 b
                    247: switch-to-buffer-other-window
                    248: .It C-x 4 f
                    249: find-file-other-window
                    250: .It C-x =
                    251: what-cursor-position
                    252: .It C-x ^
                    253: enlarge-window
                    254: .It C-x `
                    255: next-error
                    256: .It C-x b
                    257: switch-to-buffer
                    258: .It C-x d
                    259: dired
                    260: .It C-x e
                    261: call-last-kbd-macro
                    262: .It C-x f
                    263: set-fill-column
                    264: .It C-x g
                    265: goto-line
1.59      lum       266: .It C-x h
                    267: mark-whole-buffer
1.37      kjell     268: .It C-x i
                    269: insert-file
                    270: .It C-x k
                    271: kill-buffer
                    272: .It C-x n
                    273: other-window
                    274: .It C-x o
                    275: other-window
                    276: .It C-x p
                    277: previous-window
                    278: .It C-x s
                    279: save-some-buffers
                    280: .It C-x u
                    281: undo
                    282: .It C-y
                    283: yank
                    284: .It C-z
                    285: suspend-emacs
                    286: .It M-C-v
                    287: scroll-other-window
                    288: .It M-SPC
                    289: just-one-space
1.76      lum       290: .It M-!
                    291: shell-command
1.56      lum       292: .It M-.
                    293: find-tag
                    294: .It M-*
                    295: pop-tag-mark
1.23      deraadt   296: .It M-%
1.37      kjell     297: query-replace
1.4       deraadt   298: .It M-<
1.37      kjell     299: beginning-of-buffer
1.4       deraadt   300: .It M->
1.37      kjell     301: end-of-buffer
                    302: .It M-\e
                    303: delete-horizontal-space
1.49      kjell     304: .It M-^
                    305: join-line
1.37      kjell     306: .It M-b
                    307: backward-word
                    308: .It M-c
                    309: capitalize-word
                    310: .It M-d
                    311: kill-word
                    312: .It M-f
                    313: forward-word
1.92      lum       314: .It M-h
                    315: mark-paragraph
1.37      kjell     316: .It M-l
                    317: downcase-word
1.48      kjell     318: .It M-m
                    319: back-to-indentation
1.37      kjell     320: .It M-q
                    321: fill-paragraph
                    322: .It M-r
                    323: search-backward
                    324: .It M-s
                    325: search-forward
1.99      lum       326: .It M-t
                    327: transpose-words
1.37      kjell     328: .It M-u
                    329: upcase-word
                    330: .It M-v
                    331: scroll-down
                    332: .It M-w
                    333: copy-region-as-kill
                    334: .It M-x
                    335: execute-extended-command
1.127     op        336: .It M-z
                    337: zap-to-char
1.37      kjell     338: .It M-{
                    339: backward-paragraph
1.59      lum       340: .It M-|
                    341: shell-command-on-region
1.37      kjell     342: .It M-}
                    343: forward-paragraph
                    344: .It M-~
                    345: not-modified
                    346: .It M-DEL
                    347: backward-kill-word
                    348: .It C-_
                    349: undo
                    350: .It )
                    351: blink-and-insert
                    352: .It DEL
                    353: delete-backward-char
1.4       deraadt   354: .El
                    355: .Pp
1.37      kjell     356: For a complete description of
                    357: .Nm
                    358: commands, see
                    359: .Sx MG COMMANDS .
                    360: To see the active keybindings at any time, type
1.4       deraadt   361: .Dq M-x describe-bindings .
1.37      kjell     362: .Sh MG COMMANDS
1.33      kjell     363: Commands are invoked by
                    364: .Dq M-x ,
                    365: or by binding to a key.
                    366: Many commands take an optional numerical parameter,
                    367: .Va n .
                    368: This parameter is set either by
                    369: M-<n> (where
                    370: .Va n
                    371: is the numerical argument) before the command, or by
1.60      lum       372: one or more invocations of the universal argument, usually bound to C-u.
1.33      kjell     373: When invoked in this manner, the value of the numeric parameter to
                    374: be passed is displayed in the minibuffer before the M-x.
1.39      jmc       375: One common use of the parameter is in mode toggles (e.g.\&
1.37      kjell     376: make-backup-files).
                    377: If no parameter is supplied, the mode is toggled to its
                    378: alternate state.
                    379: If a positive parameter is supplied, the mode is forced to on.
                    380: Otherwise, it is forced to off.
                    381: .\"
                    382: .Bl -tag -width xxxxx
                    383: .It apropos
                    384: Help Apropos.
                    385: Prompt the user for a string, open the *help* buffer,
                    386: and list all
                    387: .Nm
                    388: commands that contain that string.
1.79      lum       389: .It audible-bell
                    390: Toggle the audible system bell.
1.37      kjell     391: .It auto-execute
                    392: Register an auto-execute hook; that is, specify a filename pattern
                    393: (conforming to the shell's filename globbing rules) and an associated
                    394: function to execute when a file matching the specified pattern
                    395: is read into a buffer.
                    396: .It auto-fill-mode
1.103     lum       397: Toggle auto-fill mode (sometimes called mail-mode) in the current buffer,
1.37      kjell     398: where text inserted past the fill column is automatically wrapped
                    399: to a new line.
1.103     lum       400: Can be set globally with set-default-mode.
1.37      kjell     401: .It auto-indent-mode
1.103     lum       402: Toggle indent mode in the current buffer,
                    403: where indentation is preserved after a newline.
                    404: Can be set globally with set-default-mode.
1.48      kjell     405: .It back-to-indentation
                    406: Move the dot to the first non-whitespace character on the current line.
1.62      lum       407: .It backup-to-home-directory
1.65      jmc       408: Save backup copies to a
                    409: .Pa ~/.mg.d
                    410: directory instead of working directory.
1.62      lum       411: Requires make-backup-files to be on.
1.37      kjell     412: .It backward-char
                    413: Move cursor backwards one character.
                    414: .It backward-kill-word
                    415: Kill text backwards by
                    416: .Va n
                    417: words.
                    418: .It backward-paragraph
                    419: Move cursor backwards
                    420: .Va n
                    421: paragraphs.
                    422: Paragraphs are delimited by <NL><NL> or <NL><TAB> or <NL><SPACE>.
                    423: .It backward-word
                    424: Move cursor backwards by the specified number of words.
                    425: .It beginning-of-buffer
                    426: Move cursor to the top of the buffer.
1.115     lum       427: If set, keep mark's position, otherwise set at current position.
1.114     jmc       428: A numeric argument
                    429: .Va n
1.113     lum       430: will move n/10th of the way from the top.
1.37      kjell     431: .It beginning-of-line
                    432: Move cursor to the beginning of the line.
                    433: .It blink-and-insert
                    434: Self-insert a character, then search backwards and blink its
1.68      sobrado   435: matching delimiter.
                    436: For delimiters other than
1.37      kjell     437: parenthesis, brackets, and braces, the character itself
                    438: is used as its own match.
1.117     lum       439: Can be used in the startup file with the global-set-key command.
1.37      kjell     440: .It bsmap-mode
1.60      lum       441: Toggle bsmap mode, where DEL and C-h are swapped.
1.42      sobrado   442: .It c-mode
                    443: Toggle a KNF-compliant mode for editing C program files.
1.37      kjell     444: .It call-last-kbd-macro
                    445: Invoke the keyboard macro.
                    446: .It capitalize-word
                    447: Capitalize
                    448: .Va n
                    449: words; i.e. convert the first character of the word to
                    450: upper case, and subsequent letters to lower case.
                    451: .It cd
                    452: Change the global working directory.
                    453: See also global-wd-mode.
1.73      florian   454: .It column-number-mode
                    455: Toggle whether the column number is displayed in the modeline.
1.37      kjell     456: .It copy-region-as-kill
                    457: Copy all of the characters in the region to the kill buffer,
                    458: clearing the mark afterwards.
                    459: This is a bit like a kill-region followed by a yank.
                    460: .It count-matches
                    461: Count the number of lines matching the supplied regular expression.
                    462: .It count-non-matches
                    463: Count the number of lines not matching the supplied regular expression.
1.61      lum       464: .It cscope-find-this-symbol
                    465: List the matches for the given symbol.
                    466: .It cscope-find-global-definition
                    467: List global definitions for the given literal.
                    468: .It cscope-find-called-functions
                    469: List functions called from the given function.
                    470: .It cscope-find-functions-calling-this-function
                    471: List functions calling the given function.
                    472: .It cscope-find-this-text-string
                    473: List locations matching the given text string.
                    474: .It cscope-find-egrep-pattern
                    475: List locations matching the given extended regular expression pattern.
                    476: .It cscope-find-this-file
                    477: List filenames matching the given filename.
                    478: .It cscope-find-files-including-file
                    479: List files that #include the given filename.
                    480: .It cscope-next-symbol
                    481: Navigate to the next match.
                    482: .It cscope-prev-symbol
                    483: Navigate to the previous match.
                    484: .It cscope-next-file
1.68      sobrado   485: Navigate to the next file.
1.61      lum       486: .It cscope-prev-file
                    487: Navigate to the previous file.
                    488: .It cscope-create-list-of-files-to-index
                    489: Create cscope's List and Index in the given directory.
1.37      kjell     490: .It define-key
1.39      jmc       491: Prompts the user for a named keymap (mode),
1.40      sobrado   492: a key, and an
                    493: .Nm
                    494: command, then creates a keybinding in the appropriate
1.37      kjell     495: map.
                    496: .It delete-backward-char
                    497: Delete backwards
                    498: .Va n
                    499: characters.
                    500: Like delete-char, this actually does a kill if presented
                    501: with an argument.
                    502: .It delete-blank-lines
                    503: Delete blank lines around dot.
                    504: If dot is sitting on a blank line, this command
                    505: deletes all the blank lines above and below the current line.
                    506: Otherwise, it deletes all of the blank lines after the current line.
                    507: .It delete-char
                    508: Delete
                    509: .Va n
                    510: characters forward.
                    511: If any argument is present, it kills rather than deletes,
                    512: saving the result in the kill buffer.
                    513: .It delete-horizontal-space
                    514: Delete any whitespace around the dot.
                    515: .It delete-leading-space
                    516: Delete leading whitespace on the current line.
                    517: .It delete-trailing-space
                    518: Delete trailing whitespace on the current line.
                    519: .It delete-matching-lines
                    520: Delete all lines after dot that contain a string matching
                    521: the supplied regular expression.
                    522: .It delete-non-matching-lines
1.106     jmc       523: Delete all lines after dot that don't contain a string matching
1.37      kjell     524: the supplied regular expression.
                    525: .It delete-other-windows
                    526: Make the current window the only window visible on the screen.
                    527: .It delete-window
                    528: Delete current window.
                    529: .It describe-bindings
                    530: List all global and local keybindings, putting the result in
                    531: the *help* buffer.
                    532: .It describe-key-briefly
                    533: Read a key from the keyboard, and look it up in the keymap.
                    534: Display the name of the function currently bound to the key.
1.74      florian   535: .It diff-buffer-with-file
                    536: View the differences between buffer and its associated file.
1.37      kjell     537: .It digit-argument
                    538: Process a numerical argument for keyboard-invoked functions.
1.123     lum       539: .It dired-jump
                    540: Open a dired buffer containing the current buffer's directory location.
1.37      kjell     541: .It downcase-region
                    542: Set all characters in the region to lower case.
                    543: .It downcase-word
                    544: Set characters to lower case, starting at the dot, and ending
                    545: .Va n
                    546: words away.
                    547: .It emacs-version
1.40      sobrado   548: Return an
                    549: .Nm
                    550: version string.
1.37      kjell     551: .It end-kbd-macro
                    552: Stop defining a keyboard macro.
                    553: .It end-of-buffer
                    554: Move cursor to the end of the buffer.
1.115     lum       555: If set, keep mark's position, otherwise set at current position.
1.113     lum       556: A numeric argument
1.114     jmc       557: .Va n
1.113     lum       558: will move n/10th of the way from the end.
1.37      kjell     559: .It end-of-line
1.40      sobrado   560: Move cursor to the end of the line.
1.37      kjell     561: .It enlarge-window
                    562: Enlarge the current window by shrinking either the window above
                    563: or below it.
                    564: .It eval-current-buffer
1.40      sobrado   565: Evaluate the current buffer as a series of
                    566: .Nm
                    567: commands.
1.37      kjell     568: Useful for testing
                    569: .Nm
                    570: startup files.
                    571: .It eval-expression
                    572: Get one line from the user, and run it.
                    573: Useful for testing expressions in
                    574: .Nm
                    575: startup files.
                    576: .It exchange-point-and-mark
                    577: Swap the values of "dot" and "mark" in the current window.
                    578: Return an error if no mark is set.
                    579: .It execute-extended-command
                    580: Invoke an extended command; i.e. M-x.
                    581: Call the message line routine to read in the command name and apply
                    582: autocompletion to it.
                    583: When it comes back, look the name up in the symbol table and run the
                    584: command if it is found, passing arguments as necessary.
                    585: Print an error if there is anything wrong.
                    586: .It fill-paragraph
                    587: Justify a paragraph, wrapping text at the current fill column.
                    588: .It find-file
                    589: Select a file for editing.
1.54      lum       590: First check if the file can be found
                    591: in another buffer; if it is there, just switch to that buffer.
                    592: If the file cannot be found, create a new buffer, read in the
1.37      kjell     593: file from disk, and switch to the new buffer.
                    594: .It find-file-read-only
                    595: Same as find-file, except the new buffer is set to read-only.
                    596: .It find-alternate-file
                    597: Replace the current file with an alternate one.
                    598: Semantics for finding the replacement file are the same as
1.39      jmc       599: find-file, except the current buffer is killed before the switch.
1.37      kjell     600: If the kill fails, or is aborted, revert to the original file.
                    601: .It find-file-other-window
                    602: Opens the specified file in a second buffer.
                    603: Splits the current window if necessary.
1.56      lum       604: .It find-tag
                    605: Jump to definition of tag at dot.
1.37      kjell     606: .It forward-char
                    607: Move cursor forwards (or backwards, if
                    608: .Va n
                    609: is negative)
                    610: .Va n
                    611: characters.
                    612: Returns an error if the end of buffer is reached.
                    613: .It forward-paragraph
                    614: Move forward
                    615: .Va n
                    616: paragraphs.
1.39      jmc       617: Paragraphs are delimited by <NL><NL> or <NL><TAB> or <NL><SPACE>.
1.37      kjell     618: .It forward-word
                    619: Move the cursor forward by the specified number of words.
                    620: .It global-set-key
                    621: Bind a key in the global (fundamental) key map.
                    622: .It global-unset-key
1.40      sobrado   623: Unbind a key from the global (fundamental) key map; i.e. set it to 'rescan'.
1.37      kjell     624: .It global-wd-mode
                    625: Toggle global working-directory mode.
                    626: When enabled,
                    627: .Nm
                    628: defaults to opening files (and executing commands like compile and grep)
1.39      jmc       629: relative to the global working directory.
1.37      kjell     630: When disabled, a working directory is set for each buffer.
                    631: .It goto-line
                    632: Go to a specific line.
                    633: If an argument is present, then
                    634: it is the line number, else prompt for a line number to use.
                    635: .It help-help
1.39      jmc       636: Prompts for one of (a)propos, (b)indings, des(c)ribe key briefly.
1.37      kjell     637: .It insert
                    638: Insert a string, mainly for use from macros.
                    639: .It insert-buffer
1.40      sobrado   640: Insert the contents of another buffer at dot.
1.37      kjell     641: .It insert-file
                    642: Insert a file into the current buffer at dot.
                    643: .It insert-with-wrap
                    644: Insert the bound character with word wrap.
                    645: Check to see if we're past the fill column, and if so,
                    646: justify this line.
                    647: .It isearch-backward
                    648: Use incremental searching, initially in the reverse direction.
                    649: isearch ignores any explicit arguments.
1.39      jmc       650: If invoked during macro definition or evaluation, the non-incremental
1.37      kjell     651: search-backward is invoked instead.
                    652: .It isearch-forward
                    653: Use incremental searching, initially in the forward direction.
                    654: isearch ignores any explicit arguments.
1.39      jmc       655: If invoked during macro definition or evaluation, the non-incremental
1.37      kjell     656: search-forward is invoked instead.
1.49      kjell     657: .It join-line
1.50      jmc       658: Join the current line to the previous.
                    659: If called with an argument,
1.49      kjell     660: join the next line to the current one.
1.37      kjell     661: .It just-one-space
                    662: Delete any whitespace around dot, then insert a space.
                    663: .It keyboard-quit
                    664: Abort the current action.
                    665: .It kill-buffer
                    666: Dispose of a buffer, by name.
1.43      kjell     667: If the buffer name does not start and end with an asterisk,
                    668: prompt the user if the buffer
1.37      kjell     669: has been changed.
                    670: .It kill-line
                    671: Kill line.
                    672: If called without an argument, it kills from dot to the end
                    673: of the line, unless it is at the end of the line, when it kills the
                    674: newline.
                    675: If called with an argument of 0, it kills from the start of the
                    676: line to dot.
                    677: If called with a positive argument, it kills from dot
                    678: forward over that number of newlines.
                    679: If called with a negative argument
                    680: it kills any text before dot on the current line, then it kills back
                    681: abs(n) lines.
                    682: .It kill-paragraph
                    683: Delete
                    684: .Va n
                    685: paragraphs starting with the current one.
                    686: .It kill-region
1.39      jmc       687: Kill the currently defined region.
1.37      kjell     688: .It kill-word
                    689: Delete forward
                    690: .Va n
                    691: words.
1.67      lum       692: .It leave-tmpdir-backups
                    693: Modifies the behaviour of backup-to-home-directory.
1.105     tedu      694: Backup files that would normally reside in
                    695: .Pa /tmp
1.67      lum       696: are left there and not moved to the
                    697: .Pa ~/.mg.d
                    698: directory.
1.37      kjell     699: .It line-number-mode
1.71      florian   700: Toggle whether the line number is displayed in the modeline.
1.37      kjell     701: .It list-buffers
                    702: Display the list of available buffers.
1.122     lum       703: The first column in the output indicates which buffer is active with a '>'
                    704: character.
                    705: The second column indicates which buffers are modified.
                    706: The third column indicates which buffers are read-only.
                    707: The remaining columns are self-explanatory.
1.37      kjell     708: .It load
                    709: Prompt the user for a filename, and then execute commands
                    710: from that file.
                    711: .It local-set-key
                    712: Bind a key mapping in the local (topmost) mode.
                    713: .It local-unset-key
                    714: Unbind a key mapping in the local (topmost) mode.
                    715: .It make-backup-files
                    716: Toggle generation of backup files.
1.118     solene    717: Enabled by default.
1.72      jasper    718: .It make-directory
                    719: Prompt the user for a path or directory name which is then created.
1.92      lum       720: .It mark-paragraph
1.94      lum       721: Mark
                    722: .Va n
                    723: paragraphs.
1.59      lum       724: .It mark-whole-buffer
                    725: Marks whole buffer as a region by putting dot at the beginning and mark
                    726: at the end of buffer.
1.37      kjell     727: .It meta-key-mode
                    728: When disabled, the meta key can be used to insert extended-ascii (8-bit)
                    729: characters.
                    730: When enabled, the meta key acts as usual.
                    731: .It negative-argument
1.39      jmc       732: Process a negative argument for keyboard-invoked functions.
1.37      kjell     733: .It newline
                    734: Insert a newline into the current buffer.
                    735: .It newline-and-indent
                    736: Insert a newline, then enough tabs and spaces to duplicate the indentation
                    737: of the previous line.
                    738: Assumes tabs are every eight characters.
                    739: .It next-line
                    740: Move forward
                    741: .Va n
                    742: lines.
1.129     op        743: .It no-tab-mode
                    744: Toggle notab mode.
                    745: In this mode, spaces are inserted rather than tabs.
1.37      kjell     746: .It not-modified
                    747: Turn off the modified flag in the current buffer.
                    748: .It open-line
                    749: Open up some blank space.
                    750: Essentially, insert
                    751: .Va n
                    752: newlines, then back up over them.
                    753: .It other-window
                    754: The command to make the next (down the screen) window the current
                    755: window.
                    756: There are no real errors, although the command does nothing if
                    757: there is only 1 window on the screen.
                    758: .It overwrite-mode
1.103     lum       759: Toggle overwrite mode in the current buffer,
                    760: where typing overwrites existing characters rather than inserting them.
                    761: Can be set globally with set-default-mode.
1.37      kjell     762: .It prefix-region
                    763: Inserts a prefix string before each line of a region.
1.131     op        764: The prefix string is settable by using 'set-prefix-string'
                    765: or by invoking this command with a prefix argument.
1.37      kjell     766: .It previous-line
                    767: Move backwards
                    768: .Va n
                    769: lines.
                    770: .It previous-window
                    771: This command makes the previous (up the screen) window the
                    772: current window.
                    773: There are no errors, although the command does not do
                    774: a lot if there is only 1 window.
1.56      lum       775: .It pop-tag-mark
                    776: Return to position where find-tag was previously invoked.
1.37      kjell     777: .It push-shell
1.40      sobrado   778: Suspend
                    779: .Nm
                    780: and switch to alternate screen, if available.
1.37      kjell     781: .It pwd
                    782: Display current (global) working directory in the status area.
                    783: .It query-replace
                    784: Query Replace.
                    785: Search and replace strings selectively, prompting after each match.
1.124     lum       786: .It replace-regexp
                    787: Replace regular expression globally without individual prompting.
1.37      kjell     788: .It replace-string
                    789: Replace string globally without individual prompting.
                    790: .It query-replace-regexp
                    791: Replace strings selectively.
                    792: Does a search and replace operation using regular
                    793: expressions for both patterns.
                    794: .It quoted-insert
                    795: Insert the next character verbatim into the current buffer; i.e. ignore
                    796: any function bound to that key.
                    797: .It re-search-again
                    798: Perform a regular expression search again, using the same search
                    799: string and direction as the last search command.
                    800: .It re-search-backward
                    801: Search backwards using a regular expression.
                    802: Get a search string from the user, and search, starting at dot
                    803: and proceeding toward the front of the buffer.
1.39      jmc       804: If found, dot is left
1.37      kjell     805: pointing at the first character of the pattern [the last character that
                    806: was matched].
                    807: .It re-search-forward
                    808: Search forward using a regular expression.
                    809: Get a search string from the user and search for it starting at dot.
                    810: If found, move dot to just after the matched characters.
                    811: display does all
                    812: the hard stuff.
                    813: If not found, it just prints a message.
                    814: .It recenter
                    815: Reposition dot in the current window.
1.39      jmc       816: By default, the dot is centered.
1.37      kjell     817: If given a positive argument (n), the display is repositioned to line
                    818: n.
                    819: If
                    820: .Va n
1.40      sobrado   821: is negative, it is that line from the bottom.
1.37      kjell     822: .It redraw-display
                    823: Refresh the display.
                    824: Recomputes all window sizes in case something has changed.
1.69      jasper    825: .It revert-buffer
                    826: Revert the current buffer to the latest file on disk.
1.37      kjell     827: .It save-buffer
                    828: Save the contents of the current buffer if it has been changed,
                    829: optionally creating a backup copy.
                    830: .It save-buffers-kill-emacs
1.40      sobrado   831: Offer to save modified buffers and quit
                    832: .Nm .
1.37      kjell     833: .It save-some-buffers
                    834: Look through the list of buffers, offering to save any buffer that
                    835: has been changed.
                    836: Buffers that are not associated with files (such
                    837: as *scratch*, *grep*, *compile*) are ignored.
                    838: .It scroll-down
                    839: Scroll backwards
                    840: .Va n
                    841: pages.
                    842: A two-line overlap between pages is
                    843: assumed.
                    844: If given a repeat argument, scrolls back lines, not pages.
                    845: .It scroll-one-line-down
                    846: Scroll the display down
                    847: .Va n
                    848: lines without changing the cursor position.
                    849: .It scroll-one-line-up
                    850: Scroll the display
                    851: .Va n
1.40      sobrado   852: lines up without moving the cursor position.
1.37      kjell     853: .It scroll-other-window
                    854: Scroll the next window in the window list window forward
                    855: .Va n
                    856: pages.
                    857: .It scroll-up
                    858: Scroll forward one page.
                    859: A two-line overlap between pages is
                    860: assumed.
                    861: If given a repeat argument, scrolls back lines, not pages.
                    862: .It search-again
                    863: Search again, using the same search string and direction as the last
                    864: search command.
                    865: .It search-backward
                    866: Reverse search.
                    867: Get a search string from the user, and search, starting
                    868: at dot and proceeding toward the front of the buffer.
                    869: If found, dot is
                    870: left pointing at the first character of the pattern (the last character
                    871: that was matched).
                    872: .It search-forward
                    873: Search forward.
                    874: Get a search string from the user, and search for it
                    875: starting at dot.
                    876: If found, dot gets moved to just after the matched
                    877: characters, if not found, print a message.
                    878: .It self-insert-command
                    879: Insert a character.
1.104     lum       880: .It sentence-end-double-space
                    881: Toggle double or single spaces for end of sentences.
                    882: Double is the default.
                    883: Currently only affects fill-paragraph.
1.37      kjell     884: .It set-case-fold-search
1.58      lum       885: Set case-fold searching, causing case not to matter
1.37      kjell     886: in regular expression searches.
1.107     reyk      887: This is the default.
                    888: .It set-case-replace
                    889: Preserve the case of the replaced string.
1.37      kjell     890: This is the default.
                    891: .It set-default-mode
                    892: Append the supplied mode to the list of default modes
                    893: used by subsequent buffer creation.
1.102     lum       894: Built in modes include: fill, indent and overwrite.
1.37      kjell     895: .It set-fill-column
                    896: Prompt the user for a fill column.
                    897: Used by auto-fill-mode.
                    898: .It set-mark-command
1.40      sobrado   899: Sets the mark in the current window to the current dot location.
1.37      kjell     900: .It set-prefix-string
                    901: Sets the prefix string to be used by the 'prefix-region' command.
1.130     op        902: .It set-tab-width
                    903: Set the tab width for the current buffer, or the default for new buffers
                    904: if called with a prefix argument or from the startup file.
1.76      lum       905: .It shell-command
                    906: Execute external command from mini-buffer.
1.59      lum       907: .It shell-command-on-region
                    908: Provide the text in region to the shell command as input.
1.37      kjell     909: .It shrink-window
                    910: Shrink current window by one line.
                    911: The window immediately below is expanded to pick up the slack.
                    912: If only one window is present, this command has no effect.
                    913: .It split-window-vertically
                    914: Split the current window.
                    915: A window smaller than 3 lines cannot be split.
                    916: .It start-kbd-macro
                    917: Start defining a keyboard macro.
                    918: Macro definition is ended by invoking end-kbd-macro.
                    919: .It suspend-emacs
1.40      sobrado   920: Suspend
                    921: .Nm
                    922: and switch back to alternate screen, if in use.
1.37      kjell     923: .It switch-to-buffer
                    924: Prompt and switch to a new buffer in the current window.
                    925: .It switch-to-buffer-other-window
                    926: Switch to buffer in another window.
                    927: .It toggle-read-only
                    928: Toggle the read-only flag on the current buffer.
1.109     lum       929: .It toggle-read-only-all
                    930: Toggle the read-only flag on all non-ephemeral buffers.
                    931: A simple toggle that switches a global read-only flag either on
                    932: or off.
1.37      kjell     933: .It transpose-chars
1.86      lum       934: Transpose the two characters in front of and under dot,
                    935: then move forward one character.
1.87      jmc       936: Treat newline characters the same as any other.
1.93      lum       937: .It transpose-paragraphs
                    938: Transpose adjacent paragraphs.
                    939: If multiple iterations are requested, the current paragraph will
1.94      lum       940: be moved
                    941: .Va n
                    942: paragraphs forward.
1.99      lum       943: .It transpose-words
                    944: Transpose adjacent words.
1.37      kjell     945: .It undo
                    946: Undo the most recent action.
                    947: If invoked again without an intervening command,
                    948: move the undo pointer to the previous action and undo it.
1.41      kjell     949: .It undo-boundary
                    950: Add an undo boundary.
                    951: This is not usually done interactively.
                    952: .It undo-boundary-toggle
                    953: Toggle whether undo boundaries are generated.
                    954: Undo boundaries are often disabled before operations that should
                    955: be considered atomically undoable.
                    956: .It undo-enable
                    957: Toggle whether undo information is kept.
1.37      kjell     958: .It undo-list
                    959: Show the undo records for the current buffer in a new buffer.
                    960: .It universal-argument
                    961: Repeat the next command 4 times.
                    962: Usually bound to C-u.
1.39      jmc       963: This command may be stacked; e.g.\&
1.37      kjell     964: C-u C-u C-f moves the cursor forward 16 characters.
                    965: .It upcase-region
                    966: Upper case region.
                    967: Change all of the lower case characters in the region to
1.40      sobrado   968: upper case.
1.37      kjell     969: .It upcase-word
                    970: Move the cursor forward by the specified number of words.
1.54      lum       971: As it moves, convert any characters to upper case.
1.79      lum       972: .It visible-bell
1.81      jmc       973: Toggle the visible bell.
                    974: If this toggle is on, the modeline will flash.
1.56      lum       975: .It visit-tags-table
1.128     op        976: Load tags file to be used for subsequent find-tag.
1.37      kjell     977: .It what-cursor-position
                    978: Display a bunch of useful information about the current location of
                    979: dot.
                    980: The character under the cursor (in octal), the current line, row,
                    981: and column, and approximate position of the cursor in the file (as a
                    982: percentage) is displayed.
                    983: The column position assumes an infinite
                    984: position display; it does not truncate just because the screen does.
                    985: .It write-file
                    986: Ask for a file name and write the contents of the current buffer to
                    987: that file.
                    988: Update the remembered file name and clear the buffer
                    989: changed flag.
                    990: .It yank
                    991: Yank text from kill-buffer.
1.40      sobrado   992: Unlike emacs, the
                    993: .Nm
                    994: kill buffer consists only
1.37      kjell     995: of the most recent kill.
                    996: It is not a ring.
1.127     op        997: .It zap-to-char
                    998: Ask for a character and delete text from the current cursor position
                    999: until the next instance of that character, including it.
                   1000: .It zap-up-to-char
                   1001: Like zap-to-char but doesn't delete the target character.
1.80      lum      1002: .El
                   1003: .Sh MG DIRED KEY BINDINGS
                   1004: Specific key bindings are available in dired mode.
                   1005: .Pp
1.100     lum      1006: .Bl -tag -width xxxxxxxxxxxxxxxxxx -offset indent -compact
1.85      lum      1007: .It DEL
                   1008: dired-unmark-backward
1.96      lum      1009: .It RET, e, f and C-m
                   1010: dired-find-file
1.108     lum      1011: .It SPC, n
1.80      lum      1012: dired-next-line
                   1013: .It !
                   1014: dired-shell-command
                   1015: .It +
                   1016: dired-create-directory
1.101     lum      1017: .It a
                   1018: dired-find-alternate-file
1.80      lum      1019: .It c
1.82      lum      1020: dired-do-copy
1.80      lum      1021: .It d and C-d
1.82      lum      1022: dired-flag-file-deletion
1.84      lum      1023: .It g
                   1024: dired-revert
1.116     lum      1025: .It j
                   1026: dired-goto-file
1.80      lum      1027: .It o
                   1028: dired-find-file-other-window
                   1029: .It p
                   1030: dired-previous-line
1.83      lum      1031: .It q
                   1032: quit-window
1.80      lum      1033: .It r
1.82      lum      1034: dired-do-rename
1.80      lum      1035: .It u
1.82      lum      1036: dired-unmark
1.80      lum      1037: .It x
1.82      lum      1038: dired-do-flagged-delete
1.80      lum      1039: .It C-v
                   1040: dired-scroll-down
                   1041: .It M-v
                   1042: dired-scroll-up
1.78      jmc      1043: .El
1.77      lum      1044: .Sh MG DIRED COMMANDS
                   1045: The following are a list of the commands specific to dired mode:
                   1046: .Bl -tag -width Ds
                   1047: .It dired-create-directory
                   1048: Create a directory.
1.82      lum      1049: .It dired-do-copy
                   1050: Copy the file listed on the current line of the dired buffer.
                   1051: .It dired-do-flagged-delete
1.77      lum      1052: Delete the files that have been flagged for deletion.
1.82      lum      1053: .It dired-do-rename
                   1054: Rename the file listed on the current line of the dired buffer.
1.101     lum      1055: .It dired-find-alternate-file
                   1056: Replace the current dired buffer with an alternate one as specified
                   1057: by the position of the cursor in the dired buffer.
1.77      lum      1058: .It dired-find-file
                   1059: Open the file on the current line of the dired buffer.
1.126     naddy    1060: If the cursor is on a directory, it will be opened in dired mode.
1.82      lum      1061: .It dired-flag-file-deletion
1.77      lum      1062: Flag the file listed on the current line for deletion.
                   1063: This is indicated in the buffer by putting a D at the left margin.
1.91      lum      1064: No files are actually deleted until the function dired-do-flagged-delete
1.77      lum      1065: is executed.
1.82      lum      1066: .It dired-find-file-other-window
                   1067: Open the file on the current line of the dired buffer in a
                   1068: different window.
1.116     lum      1069: .It dired-goto-file
                   1070: Move the cursor to a file name in the dired buffer.
1.77      lum      1071: .It dired-next-line
                   1072: Move the cursor to the next line.
                   1073: .It dired-other-window
                   1074: This function works just like dired, except that it puts the
                   1075: dired buffer in another window.
                   1076: .It dired-previous-line
                   1077: Move the cursor to the previous line.
1.84      lum      1078: .It dired-revert
1.108     lum      1079: Refresh the dired buffer while retaining any flags.
1.77      lum      1080: .It dired-scroll-down
                   1081: Scroll down the dired buffer.
                   1082: .It dired-scroll-up
                   1083: Scroll up the dired buffer.
1.125     lum      1084: .It dired-shell-command
                   1085: Pipe the file under the current cursor position through a shell command.
1.82      lum      1086: .It dired-unmark
1.77      lum      1087: Remove the deletion flag for the file on the current line.
1.82      lum      1088: .It dired-unmark-backward
1.85      lum      1089: Remove the deletion flag from the file listed on the previous line
                   1090: of the dired buffer, then move up to that line.
1.83      lum      1091: .It quit-window
                   1092: Close the current dired buffer.
1.37      kjell    1093: .El
1.33      kjell    1094: .Sh CONFIGURATION FILES
1.7       aaron    1095: There are two configuration files,
1.65      jmc      1096: .Pa .mg
1.1       deraadt  1097: and
1.3       aaron    1098: .Pa .mg-TERM .
                   1099: Here,
                   1100: .Ev TERM
1.65      jmc      1101: represents the name of the terminal type; e.g. if the terminal type
1.3       aaron    1102: is set to
                   1103: .Dq vt100 ,
1.2       deraadt  1104: .Nm
1.1       deraadt  1105: will use
1.3       aaron    1106: .Pa .mg-vt100
1.6       aaron    1107: as a startup file.
                   1108: The terminal type startup file is used first.
1.33      kjell    1109: .Pp
1.28      jmc      1110: The startup file format is a list of commands, one per line, as used for
1.33      kjell    1111: interactive evaluation.
                   1112: Strings that are normally entered by the user at any subsequent prompts
                   1113: may be specified after the command name; e.g.:
1.28      jmc      1114: .Bd -literal -offset indent
1.37      kjell    1115: global-set-key ")" self-insert-command
1.46      jmc      1116: global-set-key "\e^x\e^f" find-file
                   1117: global-set-key "\ee[Z" backward-char
1.37      kjell    1118: set-default-mode fill
1.28      jmc      1119: set-fill-column 72
1.37      kjell    1120: auto-execute *.c c-mode
1.28      jmc      1121: .Ed
1.88      lum      1122: .Pp
                   1123: Comments can be added to the startup files by placing
1.111     jmc      1124: .Sq ;\&
1.88      lum      1125: or
1.111     jmc      1126: .Sq #
1.88      lum      1127: as the first character of a line.
1.3       aaron    1128: .Sh FILES
1.55      lum      1129: .Bl -tag -width /usr/share/doc/mg/tutorial -compact
1.3       aaron    1130: .It Pa ~/.mg
                   1131: normal startup file
                   1132: .It Pa ~/.mg-TERM
                   1133: terminal-specific startup file
1.63      lum      1134: .It Pa ~/.mg.d
                   1135: alternative backup file location
1.52      lum      1136: .It Pa /usr/share/doc/mg/tutorial
1.51      lum      1137: concise tutorial
1.3       aaron    1138: .El
                   1139: .Sh SEE ALSO
1.56      lum      1140: .Xr ctags 1 ,
1.2       deraadt  1141: .Xr vi 1
1.29      reyk     1142: .Sh CAVEATS
1.37      kjell    1143: Since it is written completely in C, there is currently no
1.54      lum      1144: language in which extensions can be written;
                   1145: however, keys can be rebound and certain parameters can be changed
1.38      kjell    1146: in startup files.
1.33      kjell    1147: .Pp
                   1148: In order to use 8-bit characters (such as German umlauts), the Meta key
                   1149: needs to be disabled via the
                   1150: .Dq meta-key-mode
                   1151: command.
1.75      naddy    1152: .Pp
                   1153: Multi-byte character sets, such as UTF-8, are not supported.