Annotation of src/usr.bin/mg/mg.1, Revision 1.114
1.114 ! jmc 1: .\" $OpenBSD: mg.1,v 1.113 2019/06/03 16:26:30 lum Exp $
1.34 kjell 2: .\" This file is in the public domain.
1.9 niklas 3: .\"
1.114 ! jmc 4: .Dd $Mdocdate: June 3 2019 $
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.105 tedu 97: Further, if any application creates backup files in
98: .Pa /tmp ,
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
1.103 lum 378: Toggle auto-fill mode (sometimes called mail-mode) in the current buffer,
1.37 kjell 379: where text inserted past the fill column is automatically wrapped
380: to a new line.
1.103 lum 381: Can be set globally with set-default-mode.
1.37 kjell 382: .It auto-indent-mode
1.103 lum 383: Toggle indent mode in the current buffer,
384: where indentation is preserved after a newline.
385: Can be set globally with set-default-mode.
1.48 kjell 386: .It back-to-indentation
387: Move the dot to the first non-whitespace character on the current line.
1.62 lum 388: .It backup-to-home-directory
1.65 jmc 389: Save backup copies to a
390: .Pa ~/.mg.d
391: directory instead of working directory.
1.62 lum 392: Requires make-backup-files to be on.
1.37 kjell 393: .It backward-char
394: Move cursor backwards one character.
395: .It backward-kill-word
396: Kill text backwards by
397: .Va n
398: words.
399: .It backward-paragraph
400: Move cursor backwards
401: .Va n
402: paragraphs.
403: Paragraphs are delimited by <NL><NL> or <NL><TAB> or <NL><SPACE>.
404: .It backward-word
405: Move cursor backwards by the specified number of words.
406: .It beginning-of-buffer
407: Move cursor to the top of the buffer.
1.114 ! jmc 408: A numeric argument
! 409: .Va n
1.113 lum 410: will move n/10th of the way from the top.
1.37 kjell 411: .It beginning-of-line
412: Move cursor to the beginning of the line.
413: .It blink-and-insert
414: Self-insert a character, then search backwards and blink its
1.68 sobrado 415: matching delimiter.
416: For delimiters other than
1.37 kjell 417: parenthesis, brackets, and braces, the character itself
418: is used as its own match.
419: .It bsmap-mode
1.60 lum 420: Toggle bsmap mode, where DEL and C-h are swapped.
1.42 sobrado 421: .It c-mode
422: Toggle a KNF-compliant mode for editing C program files.
1.37 kjell 423: .It call-last-kbd-macro
424: Invoke the keyboard macro.
425: .It capitalize-word
426: Capitalize
427: .Va n
428: words; i.e. convert the first character of the word to
429: upper case, and subsequent letters to lower case.
430: .It cd
431: Change the global working directory.
432: See also global-wd-mode.
1.73 florian 433: .It column-number-mode
434: Toggle whether the column number is displayed in the modeline.
1.37 kjell 435: .It copy-region-as-kill
436: Copy all of the characters in the region to the kill buffer,
437: clearing the mark afterwards.
438: This is a bit like a kill-region followed by a yank.
439: .It count-matches
440: Count the number of lines matching the supplied regular expression.
441: .It count-non-matches
442: Count the number of lines not matching the supplied regular expression.
1.61 lum 443: .It cscope-find-this-symbol
444: List the matches for the given symbol.
445: .It cscope-find-global-definition
446: List global definitions for the given literal.
447: .It cscope-find-called-functions
448: List functions called from the given function.
449: .It cscope-find-functions-calling-this-function
450: List functions calling the given function.
451: .It cscope-find-this-text-string
452: List locations matching the given text string.
453: .It cscope-find-egrep-pattern
454: List locations matching the given extended regular expression pattern.
455: .It cscope-find-this-file
456: List filenames matching the given filename.
457: .It cscope-find-files-including-file
458: List files that #include the given filename.
459: .It cscope-next-symbol
460: Navigate to the next match.
461: .It cscope-prev-symbol
462: Navigate to the previous match.
463: .It cscope-next-file
1.68 sobrado 464: Navigate to the next file.
1.61 lum 465: .It cscope-prev-file
466: Navigate to the previous file.
467: .It cscope-create-list-of-files-to-index
468: Create cscope's List and Index in the given directory.
1.37 kjell 469: .It define-key
1.39 jmc 470: Prompts the user for a named keymap (mode),
1.40 sobrado 471: a key, and an
472: .Nm
473: command, then creates a keybinding in the appropriate
1.37 kjell 474: map.
475: .It delete-backward-char
476: Delete backwards
477: .Va n
478: characters.
479: Like delete-char, this actually does a kill if presented
480: with an argument.
481: .It delete-blank-lines
482: Delete blank lines around dot.
483: If dot is sitting on a blank line, this command
484: deletes all the blank lines above and below the current line.
485: Otherwise, it deletes all of the blank lines after the current line.
486: .It delete-char
487: Delete
488: .Va n
489: characters forward.
490: If any argument is present, it kills rather than deletes,
491: saving the result in the kill buffer.
492: .It delete-horizontal-space
493: Delete any whitespace around the dot.
494: .It delete-leading-space
495: Delete leading whitespace on the current line.
496: .It delete-trailing-space
497: Delete trailing whitespace on the current line.
498: .It delete-matching-lines
499: Delete all lines after dot that contain a string matching
500: the supplied regular expression.
501: .It delete-non-matching-lines
1.106 jmc 502: Delete all lines after dot that don't contain a string matching
1.37 kjell 503: the supplied regular expression.
504: .It delete-other-windows
505: Make the current window the only window visible on the screen.
506: .It delete-window
507: Delete current window.
508: .It describe-bindings
509: List all global and local keybindings, putting the result in
510: the *help* buffer.
511: .It describe-key-briefly
512: Read a key from the keyboard, and look it up in the keymap.
513: Display the name of the function currently bound to the key.
1.74 florian 514: .It diff-buffer-with-file
515: View the differences between buffer and its associated file.
1.37 kjell 516: .It digit-argument
517: Process a numerical argument for keyboard-invoked functions.
518: .It downcase-region
519: Set all characters in the region to lower case.
520: .It downcase-word
521: Set characters to lower case, starting at the dot, and ending
522: .Va n
523: words away.
524: .It emacs-version
1.40 sobrado 525: Return an
526: .Nm
527: version string.
1.37 kjell 528: .It end-kbd-macro
529: Stop defining a keyboard macro.
530: .It end-of-buffer
531: Move cursor to the end of the buffer.
1.113 lum 532: A numeric argument
1.114 ! jmc 533: .Va n
1.113 lum 534: will move n/10th of the way from the end.
1.37 kjell 535: .It end-of-line
1.40 sobrado 536: Move cursor to the end of the line.
1.37 kjell 537: .It enlarge-window
538: Enlarge the current window by shrinking either the window above
539: or below it.
540: .It eval-current-buffer
1.40 sobrado 541: Evaluate the current buffer as a series of
542: .Nm
543: commands.
1.37 kjell 544: Useful for testing
545: .Nm
546: startup files.
547: .It eval-expression
548: Get one line from the user, and run it.
549: Useful for testing expressions in
550: .Nm
551: startup files.
552: .It exchange-point-and-mark
553: Swap the values of "dot" and "mark" in the current window.
554: Return an error if no mark is set.
555: .It execute-extended-command
556: Invoke an extended command; i.e. M-x.
557: Call the message line routine to read in the command name and apply
558: autocompletion to it.
559: When it comes back, look the name up in the symbol table and run the
560: command if it is found, passing arguments as necessary.
561: Print an error if there is anything wrong.
562: .It fill-paragraph
563: Justify a paragraph, wrapping text at the current fill column.
564: .It find-file
565: Select a file for editing.
1.54 lum 566: First check if the file can be found
567: in another buffer; if it is there, just switch to that buffer.
568: If the file cannot be found, create a new buffer, read in the
1.37 kjell 569: file from disk, and switch to the new buffer.
570: .It find-file-read-only
571: Same as find-file, except the new buffer is set to read-only.
572: .It find-alternate-file
573: Replace the current file with an alternate one.
574: Semantics for finding the replacement file are the same as
1.39 jmc 575: find-file, except the current buffer is killed before the switch.
1.37 kjell 576: If the kill fails, or is aborted, revert to the original file.
577: .It find-file-other-window
578: Opens the specified file in a second buffer.
579: Splits the current window if necessary.
1.56 lum 580: .It find-tag
581: Jump to definition of tag at dot.
1.37 kjell 582: .It forward-char
583: Move cursor forwards (or backwards, if
584: .Va n
585: is negative)
586: .Va n
587: characters.
588: Returns an error if the end of buffer is reached.
589: .It forward-paragraph
590: Move forward
591: .Va n
592: paragraphs.
1.39 jmc 593: Paragraphs are delimited by <NL><NL> or <NL><TAB> or <NL><SPACE>.
1.37 kjell 594: .It forward-word
595: Move the cursor forward by the specified number of words.
596: .It global-set-key
597: Bind a key in the global (fundamental) key map.
598: .It global-unset-key
1.40 sobrado 599: Unbind a key from the global (fundamental) key map; i.e. set it to 'rescan'.
1.37 kjell 600: .It global-wd-mode
601: Toggle global working-directory mode.
602: When enabled,
603: .Nm
604: defaults to opening files (and executing commands like compile and grep)
1.39 jmc 605: relative to the global working directory.
1.37 kjell 606: When disabled, a working directory is set for each buffer.
607: .It goto-line
608: Go to a specific line.
609: If an argument is present, then
610: it is the line number, else prompt for a line number to use.
611: .It help-help
1.39 jmc 612: Prompts for one of (a)propos, (b)indings, des(c)ribe key briefly.
1.37 kjell 613: .It insert
614: Insert a string, mainly for use from macros.
615: .It insert-buffer
1.40 sobrado 616: Insert the contents of another buffer at dot.
1.37 kjell 617: .It insert-file
618: Insert a file into the current buffer at dot.
619: .It insert-with-wrap
620: Insert the bound character with word wrap.
621: Check to see if we're past the fill column, and if so,
622: justify this line.
623: .It isearch-backward
624: Use incremental searching, initially in the reverse direction.
625: isearch ignores any explicit arguments.
1.39 jmc 626: If invoked during macro definition or evaluation, the non-incremental
1.37 kjell 627: search-backward is invoked instead.
628: .It isearch-forward
629: Use incremental searching, initially in the forward direction.
630: isearch ignores any explicit arguments.
1.39 jmc 631: If invoked during macro definition or evaluation, the non-incremental
1.37 kjell 632: search-forward is invoked instead.
1.49 kjell 633: .It join-line
1.50 jmc 634: Join the current line to the previous.
635: If called with an argument,
1.49 kjell 636: join the next line to the current one.
1.37 kjell 637: .It just-one-space
638: Delete any whitespace around dot, then insert a space.
639: .It keyboard-quit
640: Abort the current action.
641: .It kill-buffer
642: Dispose of a buffer, by name.
1.43 kjell 643: If the buffer name does not start and end with an asterisk,
644: prompt the user if the buffer
1.37 kjell 645: has been changed.
646: .It kill-line
647: Kill line.
648: If called without an argument, it kills from dot to the end
649: of the line, unless it is at the end of the line, when it kills the
650: newline.
651: If called with an argument of 0, it kills from the start of the
652: line to dot.
653: If called with a positive argument, it kills from dot
654: forward over that number of newlines.
655: If called with a negative argument
656: it kills any text before dot on the current line, then it kills back
657: abs(n) lines.
658: .It kill-paragraph
659: Delete
660: .Va n
661: paragraphs starting with the current one.
662: .It kill-region
1.39 jmc 663: Kill the currently defined region.
1.37 kjell 664: .It kill-word
665: Delete forward
666: .Va n
667: words.
1.67 lum 668: .It leave-tmpdir-backups
669: Modifies the behaviour of backup-to-home-directory.
1.105 tedu 670: Backup files that would normally reside in
671: .Pa /tmp
1.67 lum 672: are left there and not moved to the
673: .Pa ~/.mg.d
674: directory.
1.37 kjell 675: .It line-number-mode
1.71 florian 676: Toggle whether the line number is displayed in the modeline.
1.37 kjell 677: .It list-buffers
678: Display the list of available buffers.
679: .It load
680: Prompt the user for a filename, and then execute commands
681: from that file.
682: .It local-set-key
683: Bind a key mapping in the local (topmost) mode.
684: .It local-unset-key
685: Unbind a key mapping in the local (topmost) mode.
686: .It make-backup-files
687: Toggle generation of backup files.
1.72 jasper 688: .It make-directory
689: Prompt the user for a path or directory name which is then created.
1.92 lum 690: .It mark-paragraph
1.94 lum 691: Mark
692: .Va n
693: paragraphs.
1.59 lum 694: .It mark-whole-buffer
695: Marks whole buffer as a region by putting dot at the beginning and mark
696: at the end of buffer.
1.37 kjell 697: .It meta-key-mode
698: When disabled, the meta key can be used to insert extended-ascii (8-bit)
699: characters.
700: When enabled, the meta key acts as usual.
701: .It negative-argument
1.39 jmc 702: Process a negative argument for keyboard-invoked functions.
1.37 kjell 703: .It newline
704: Insert a newline into the current buffer.
705: .It newline-and-indent
706: Insert a newline, then enough tabs and spaces to duplicate the indentation
707: of the previous line.
708: Assumes tabs are every eight characters.
709: .It next-line
710: Move forward
711: .Va n
712: lines.
1.89 jmc 713: .\" .It no-tab-mode
714: .\" Toggle notab mode.
715: .\" In this mode, spaces are inserted rather than tabs.
1.37 kjell 716: .It not-modified
717: Turn off the modified flag in the current buffer.
718: .It open-line
719: Open up some blank space.
720: Essentially, insert
721: .Va n
722: newlines, then back up over them.
723: .It other-window
724: The command to make the next (down the screen) window the current
725: window.
726: There are no real errors, although the command does nothing if
727: there is only 1 window on the screen.
728: .It overwrite-mode
1.103 lum 729: Toggle overwrite mode in the current buffer,
730: where typing overwrites existing characters rather than inserting them.
731: Can be set globally with set-default-mode.
1.37 kjell 732: .It prefix-region
733: Inserts a prefix string before each line of a region.
734: The prefix string is settable by using 'set-prefix-string'.
735: .It previous-line
736: Move backwards
737: .Va n
738: lines.
739: .It previous-window
740: This command makes the previous (up the screen) window the
741: current window.
742: There are no errors, although the command does not do
743: a lot if there is only 1 window.
1.56 lum 744: .It pop-tag-mark
745: Return to position where find-tag was previously invoked.
1.37 kjell 746: .It push-shell
1.40 sobrado 747: Suspend
748: .Nm
749: and switch to alternate screen, if available.
1.37 kjell 750: .It pwd
751: Display current (global) working directory in the status area.
752: .It query-replace
753: Query Replace.
754: Search and replace strings selectively, prompting after each match.
755: .It replace-string
756: Replace string globally without individual prompting.
757: .It query-replace-regexp
758: Replace strings selectively.
759: Does a search and replace operation using regular
760: expressions for both patterns.
761: .It quoted-insert
762: Insert the next character verbatim into the current buffer; i.e. ignore
763: any function bound to that key.
764: .It re-search-again
765: Perform a regular expression search again, using the same search
766: string and direction as the last search command.
767: .It re-search-backward
768: Search backwards using a regular expression.
769: Get a search string from the user, and search, starting at dot
770: and proceeding toward the front of the buffer.
1.39 jmc 771: If found, dot is left
1.37 kjell 772: pointing at the first character of the pattern [the last character that
773: was matched].
774: .It re-search-forward
775: Search forward using a regular expression.
776: Get a search string from the user and search for it starting at dot.
777: If found, move dot to just after the matched characters.
778: display does all
779: the hard stuff.
780: If not found, it just prints a message.
781: .It recenter
782: Reposition dot in the current window.
1.39 jmc 783: By default, the dot is centered.
1.37 kjell 784: If given a positive argument (n), the display is repositioned to line
785: n.
786: If
787: .Va n
1.40 sobrado 788: is negative, it is that line from the bottom.
1.37 kjell 789: .It redraw-display
790: Refresh the display.
791: Recomputes all window sizes in case something has changed.
1.69 jasper 792: .It revert-buffer
793: Revert the current buffer to the latest file on disk.
1.37 kjell 794: .It save-buffer
795: Save the contents of the current buffer if it has been changed,
796: optionally creating a backup copy.
797: .It save-buffers-kill-emacs
1.40 sobrado 798: Offer to save modified buffers and quit
799: .Nm .
1.37 kjell 800: .It save-some-buffers
801: Look through the list of buffers, offering to save any buffer that
802: has been changed.
803: Buffers that are not associated with files (such
804: as *scratch*, *grep*, *compile*) are ignored.
805: .It scroll-down
806: Scroll backwards
807: .Va n
808: pages.
809: A two-line overlap between pages is
810: assumed.
811: If given a repeat argument, scrolls back lines, not pages.
812: .It scroll-one-line-down
813: Scroll the display down
814: .Va n
815: lines without changing the cursor position.
816: .It scroll-one-line-up
817: Scroll the display
818: .Va n
1.40 sobrado 819: lines up without moving the cursor position.
1.37 kjell 820: .It scroll-other-window
821: Scroll the next window in the window list window forward
822: .Va n
823: pages.
824: .It scroll-up
825: Scroll forward one page.
826: A two-line overlap between pages is
827: assumed.
828: If given a repeat argument, scrolls back lines, not pages.
829: .It search-again
830: Search again, using the same search string and direction as the last
831: search command.
832: .It search-backward
833: Reverse search.
834: Get a search string from the user, and search, starting
835: at dot and proceeding toward the front of the buffer.
836: If found, dot is
837: left pointing at the first character of the pattern (the last character
838: that was matched).
839: .It search-forward
840: Search forward.
841: Get a search string from the user, and search for it
842: starting at dot.
843: If found, dot gets moved to just after the matched
844: characters, if not found, print a message.
845: .It self-insert-command
846: Insert a character.
1.104 lum 847: .It sentence-end-double-space
848: Toggle double or single spaces for end of sentences.
849: Double is the default.
850: Currently only affects fill-paragraph.
1.37 kjell 851: .It set-case-fold-search
1.58 lum 852: Set case-fold searching, causing case not to matter
1.37 kjell 853: in regular expression searches.
1.107 reyk 854: This is the default.
855: .It set-case-replace
856: Preserve the case of the replaced string.
1.37 kjell 857: This is the default.
858: .It set-default-mode
859: Append the supplied mode to the list of default modes
860: used by subsequent buffer creation.
1.102 lum 861: Built in modes include: fill, indent and overwrite.
1.37 kjell 862: .It set-fill-column
863: Prompt the user for a fill column.
864: Used by auto-fill-mode.
865: .It set-mark-command
1.40 sobrado 866: Sets the mark in the current window to the current dot location.
1.37 kjell 867: .It set-prefix-string
868: Sets the prefix string to be used by the 'prefix-region' command.
1.76 lum 869: .It shell-command
870: Execute external command from mini-buffer.
1.59 lum 871: .It shell-command-on-region
872: Provide the text in region to the shell command as input.
1.37 kjell 873: .It shrink-window
874: Shrink current window by one line.
875: The window immediately below is expanded to pick up the slack.
876: If only one window is present, this command has no effect.
877: .It split-window-vertically
878: Split the current window.
879: A window smaller than 3 lines cannot be split.
880: .It start-kbd-macro
881: Start defining a keyboard macro.
882: Macro definition is ended by invoking end-kbd-macro.
883: .It suspend-emacs
1.40 sobrado 884: Suspend
885: .Nm
886: and switch back to alternate screen, if in use.
1.37 kjell 887: .It switch-to-buffer
888: Prompt and switch to a new buffer in the current window.
889: .It switch-to-buffer-other-window
890: Switch to buffer in another window.
891: .It toggle-read-only
892: Toggle the read-only flag on the current buffer.
1.109 lum 893: .It toggle-read-only-all
894: Toggle the read-only flag on all non-ephemeral buffers.
895: A simple toggle that switches a global read-only flag either on
896: or off.
1.37 kjell 897: .It transpose-chars
1.86 lum 898: Transpose the two characters in front of and under dot,
899: then move forward one character.
1.87 jmc 900: Treat newline characters the same as any other.
1.93 lum 901: .It transpose-paragraphs
902: Transpose adjacent paragraphs.
903: If multiple iterations are requested, the current paragraph will
1.94 lum 904: be moved
905: .Va n
906: paragraphs forward.
1.99 lum 907: .It transpose-words
908: Transpose adjacent words.
1.37 kjell 909: .It undo
910: Undo the most recent action.
911: If invoked again without an intervening command,
912: move the undo pointer to the previous action and undo it.
1.41 kjell 913: .It undo-boundary
914: Add an undo boundary.
915: This is not usually done interactively.
916: .It undo-boundary-toggle
917: Toggle whether undo boundaries are generated.
918: Undo boundaries are often disabled before operations that should
919: be considered atomically undoable.
920: .It undo-enable
921: Toggle whether undo information is kept.
1.37 kjell 922: .It undo-list
923: Show the undo records for the current buffer in a new buffer.
924: .It universal-argument
925: Repeat the next command 4 times.
926: Usually bound to C-u.
1.39 jmc 927: This command may be stacked; e.g.\&
1.37 kjell 928: C-u C-u C-f moves the cursor forward 16 characters.
929: .It upcase-region
930: Upper case region.
931: Change all of the lower case characters in the region to
1.40 sobrado 932: upper case.
1.37 kjell 933: .It upcase-word
934: Move the cursor forward by the specified number of words.
1.54 lum 935: As it moves, convert any characters to upper case.
1.79 lum 936: .It visible-bell
1.81 jmc 937: Toggle the visible bell.
938: If this toggle is on, the modeline will flash.
1.56 lum 939: .It visit-tags-table
940: Record name of the tags file to be used for subsequent find-tag.
1.37 kjell 941: .It what-cursor-position
942: Display a bunch of useful information about the current location of
943: dot.
944: The character under the cursor (in octal), the current line, row,
945: and column, and approximate position of the cursor in the file (as a
946: percentage) is displayed.
947: The column position assumes an infinite
948: position display; it does not truncate just because the screen does.
949: .It write-file
950: Ask for a file name and write the contents of the current buffer to
951: that file.
952: Update the remembered file name and clear the buffer
953: changed flag.
954: .It yank
955: Yank text from kill-buffer.
1.40 sobrado 956: Unlike emacs, the
957: .Nm
958: kill buffer consists only
1.37 kjell 959: of the most recent kill.
960: It is not a ring.
1.80 lum 961: .El
962: .Sh MG DIRED KEY BINDINGS
963: Specific key bindings are available in dired mode.
964: .Pp
1.100 lum 965: .Bl -tag -width xxxxxxxxxxxxxxxxxx -offset indent -compact
1.85 lum 966: .It DEL
967: dired-unmark-backward
1.96 lum 968: .It RET, e, f and C-m
969: dired-find-file
1.108 lum 970: .It SPC, n
1.80 lum 971: dired-next-line
972: .It !
973: dired-shell-command
974: .It +
975: dired-create-directory
1.101 lum 976: .It a
977: dired-find-alternate-file
1.80 lum 978: .It c
1.82 lum 979: dired-do-copy
1.80 lum 980: .It d and C-d
1.82 lum 981: dired-flag-file-deletion
1.84 lum 982: .It g
983: dired-revert
1.80 lum 984: .It o
985: dired-find-file-other-window
986: .It p
987: dired-previous-line
1.83 lum 988: .It q
989: quit-window
1.80 lum 990: .It r
1.82 lum 991: dired-do-rename
1.80 lum 992: .It u
1.82 lum 993: dired-unmark
1.80 lum 994: .It x
1.82 lum 995: dired-do-flagged-delete
1.80 lum 996: .It C-v
997: dired-scroll-down
998: .It M-v
999: dired-scroll-up
1.78 jmc 1000: .El
1.77 lum 1001: .Sh MG DIRED COMMANDS
1002: The following are a list of the commands specific to dired mode:
1003: .Bl -tag -width Ds
1004: .It dired-create-directory
1005: Create a directory.
1.82 lum 1006: .It dired-do-copy
1007: Copy the file listed on the current line of the dired buffer.
1008: .It dired-do-flagged-delete
1.77 lum 1009: Delete the files that have been flagged for deletion.
1.82 lum 1010: .It dired-do-rename
1011: Rename the file listed on the current line of the dired buffer.
1.101 lum 1012: .It dired-find-alternate-file
1013: Replace the current dired buffer with an alternate one as specified
1014: by the position of the cursor in the dired buffer.
1.77 lum 1015: .It dired-find-file
1016: Open the file on the current line of the dired buffer.
1.78 jmc 1017: If the cursor is on a directory it will be opened in dired mode.
1.82 lum 1018: .It dired-flag-file-deletion
1.77 lum 1019: Flag the file listed on the current line for deletion.
1020: This is indicated in the buffer by putting a D at the left margin.
1.91 lum 1021: No files are actually deleted until the function dired-do-flagged-delete
1.77 lum 1022: is executed.
1.82 lum 1023: .It dired-find-file-other-window
1024: Open the file on the current line of the dired buffer in a
1025: different window.
1.77 lum 1026: .It dired-next-line
1027: Move the cursor to the next line.
1028: .It dired-other-window
1029: This function works just like dired, except that it puts the
1030: dired buffer in another window.
1031: .It dired-previous-line
1032: Move the cursor to the previous line.
1.84 lum 1033: .It dired-revert
1.108 lum 1034: Refresh the dired buffer while retaining any flags.
1.77 lum 1035: .It dired-scroll-down
1036: Scroll down the dired buffer.
1037: .It dired-scroll-up
1038: Scroll up the dired buffer.
1.82 lum 1039: .It dired-unmark
1.77 lum 1040: Remove the deletion flag for the file on the current line.
1.82 lum 1041: .It dired-unmark-backward
1.85 lum 1042: Remove the deletion flag from the file listed on the previous line
1043: of the dired buffer, then move up to that line.
1.83 lum 1044: .It quit-window
1045: Close the current dired buffer.
1.37 kjell 1046: .El
1.33 kjell 1047: .Sh CONFIGURATION FILES
1.7 aaron 1048: There are two configuration files,
1.65 jmc 1049: .Pa .mg
1.1 deraadt 1050: and
1.3 aaron 1051: .Pa .mg-TERM .
1052: Here,
1053: .Ev TERM
1.65 jmc 1054: represents the name of the terminal type; e.g. if the terminal type
1.3 aaron 1055: is set to
1056: .Dq vt100 ,
1.2 deraadt 1057: .Nm
1.1 deraadt 1058: will use
1.3 aaron 1059: .Pa .mg-vt100
1.6 aaron 1060: as a startup file.
1061: The terminal type startup file is used first.
1.33 kjell 1062: .Pp
1.28 jmc 1063: The startup file format is a list of commands, one per line, as used for
1.33 kjell 1064: interactive evaluation.
1065: Strings that are normally entered by the user at any subsequent prompts
1066: may be specified after the command name; e.g.:
1.28 jmc 1067: .Bd -literal -offset indent
1.37 kjell 1068: global-set-key ")" self-insert-command
1.46 jmc 1069: global-set-key "\e^x\e^f" find-file
1070: global-set-key "\ee[Z" backward-char
1.37 kjell 1071: set-default-mode fill
1.28 jmc 1072: set-fill-column 72
1.37 kjell 1073: auto-execute *.c c-mode
1.28 jmc 1074: .Ed
1.88 lum 1075: .Pp
1076: Comments can be added to the startup files by placing
1.111 jmc 1077: .Sq ;\&
1.88 lum 1078: or
1.111 jmc 1079: .Sq #
1.88 lum 1080: as the first character of a line.
1.3 aaron 1081: .Sh FILES
1.55 lum 1082: .Bl -tag -width /usr/share/doc/mg/tutorial -compact
1.3 aaron 1083: .It Pa ~/.mg
1084: normal startup file
1085: .It Pa ~/.mg-TERM
1086: terminal-specific startup file
1.63 lum 1087: .It Pa ~/.mg.d
1088: alternative backup file location
1.52 lum 1089: .It Pa /usr/share/doc/mg/tutorial
1.51 lum 1090: concise tutorial
1.3 aaron 1091: .El
1092: .Sh SEE ALSO
1.56 lum 1093: .Xr ctags 1 ,
1.2 deraadt 1094: .Xr vi 1
1.29 reyk 1095: .Sh CAVEATS
1.37 kjell 1096: Since it is written completely in C, there is currently no
1.54 lum 1097: language in which extensions can be written;
1098: however, keys can be rebound and certain parameters can be changed
1.38 kjell 1099: in startup files.
1.33 kjell 1100: .Pp
1101: In order to use 8-bit characters (such as German umlauts), the Meta key
1102: needs to be disabled via the
1103: .Dq meta-key-mode
1104: command.
1.75 naddy 1105: .Pp
1106: Multi-byte character sets, such as UTF-8, are not supported.