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