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