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