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