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