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