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