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