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