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