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