diff options
Diffstat (limited to 'usr.bin/mg')
-rw-r--r-- | usr.bin/mg/mg.1 | 751 |
1 files changed, 677 insertions, 74 deletions
diff --git a/usr.bin/mg/mg.1 b/usr.bin/mg/mg.1 index 16f6445f488..751e54044c9 100644 --- a/usr.bin/mg/mg.1 +++ b/usr.bin/mg/mg.1 @@ -1,7 +1,7 @@ -.\" $OpenBSD: mg.1,v 1.36 2008/05/29 19:58:15 sobrado Exp $ +.\" $OpenBSD: mg.1,v 1.37 2008/06/15 07:31:41 kjell Exp $ .\" This file is in the public domain. .\" -.Dd $Mdocdate: May 29 2008 $ +.Dd $Mdocdate: June 15 2008 $ .Dt MG 1 .Os .Sh NAME @@ -54,7 +54,9 @@ If changes are made to a buffer, it will be reflected in all open windows. The current cursor location in .Nm is called the -.Em point . +.Em point +(or +.Em dot ) . It is possible to define a window-specific region of text by setting a second location, called the .Em mark . @@ -69,77 +71,198 @@ Note: The point and mark are window-specific in not buffer-specific, as in other emacs flavours. .Sh DEFAULT KEY BINDINGS Normal editing commands are very similar to Gnu Emacs. -In the following examples, ^X means control-X, and M-X means Meta-X, +In the following examples, C-x means control-X, and M-x means Meta-X, where the Meta key may be either a special key on your keyboard or the ALT key; otherwise ESC followed by the key X works as well. .Pp -.Bl -tag -width xxxxx -compact -.It ^F -Forward character. -.It ^B -Backwards character. -.It ^N -Next line. -.It ^P -Previous line. -.It ^A -Start of line. -.It ^E -End of line. -.It ^D -Delete current character. -.It ^S -Interactive search forward. -.It ^R -Interactive search backwards. +.Bl -tag -width xxxxxxxxxx -compact +.It C-SPC +set-mark-command +.It C-a +beginning-of-line +.It C-b +backward-char +.It C-d +delete-char +.It C-e +end-of-line +.It C-f +forward-char +.It C-g +keyboard-quit +.It C-h C-h +help-help +.It C-h a +apropos +.It C-h b +describe-bindings +.It C-h c +describe-key-briefly +.It C-j +newline-and-indent +.It C-k +kill-line +.It C-l +recenter +.It RET +newline +.It C-n +next-line +.It C-o +open-line +.It C-p +previous-line +.It C-q +quoted-insert +.It C-r +isearch-backward +.It C-s +isearch-forward +.It C-t +transpose-chars +.It C-u +universal-argument +.It C-v +scroll-up +.It C-w +kill-region +.It C-x C-b +list-buffers +.It C-x C-c +save-buffers-kill-emacs +.It C-x C-f +find-file +.It C-x C-g +keyboard-quit +.It C-x C-l +downcase-region +.It C-x C-o +delete-blank-lines +.It C-x C-q +toggle-read-only +.It C-x C-r +find-file-read-only +.It C-x C-s +save-buffer +.It C-x C-u +upcase-region +.It C-x C-v +find-alternate-file +.It C-x C-w +write-file +.It C-x C-x +exchange-point-and-mark +.It C-x ( +start-kbd-macro +.It C-x ) +end-kbd-macro +.It C-x 0 +delete-window +.It C-x 1 +delete-other-windows +.It C-x 2 +split-window-vertically +.It C-x 4 C-f +find-file-other-window +.It C-x 4 C-g +keyboard-quit +.It C-x 4 b +switch-to-buffer-other-window +.It C-x 4 f +find-file-other-window +.It C-x = +what-cursor-position +.It C-x ^ +enlarge-window +.It C-x ` +next-error +.It C-x b +switch-to-buffer +.It C-x d +dired +.It C-x e +call-last-kbd-macro +.It C-x f +set-fill-column +.It C-x g +goto-line +.It C-x i +insert-file +.It C-x k +kill-buffer +.It C-x n +other-window +.It C-x o +other-window +.It C-x p +previous-window +.It C-x s +save-some-buffers +.It C-x u +undo +.It C-y +yank +.It C-z +suspend-emacs +.It M-C-v +scroll-other-window +.It M-SPC +just-one-space .It M-% -Interactive search-and-replace. -.It ^O -Open a new line at cursor position. -.It ^T -Transpose characters. -.It ^U -Repeat next command 4 times -(can be cascaded i.e. ^U^U^F will move 16 characters forward). -.Pp -.It ^K -Kill to end of line (placing into kill buffer). -.It ^Y -Yank kill buffer into current location. -.It ^SPC -Set mark. -.It ^W -Kill region -(cuts from previously set mark to current location, into kill buffer). -.It M-W -Copy region (into kill buffer). -.Pp -.It ^V -Next page. -.It M-V -Previous page. +query-replace .It M-< -Start of buffer. +beginning-of-buffer .It M-> -End of buffer. -.Pp -.It ^X^C -Save buffers and quit. -.It ^X-O -Next window. -.It ^X-N -Next window. -.It ^X-P -Previous window. -.It ^X-U -Undo. -.It ^_ -Undo. +end-of-buffer +.It M-\e +delete-horizontal-space +.It M-b +backward-word +.It M-c +capitalize-word +.It M-d +kill-word +.It M-f +forward-word +.It M-l +downcase-word +.It M-q +fill-paragraph +.It M-r +search-backward +.It M-s +search-forward +.It M-u +upcase-word +.It M-v +scroll-down +.It M-w +copy-region-as-kill +.It M-x +execute-extended-command +.It M-{ +backward-paragraph +.It M-} +forward-paragraph +.It M-~ +not-modified +.It M-DEL +backward-kill-word +.It C-_ +undo +.It ) +blink-and-insert +.It DEL +delete-backward-char .El .Pp -For a complete set of key bindings, type +For a complete description of +.Nm +commands, see +.Sx MG COMMANDS . +To see the active keybindings at any time, type .Dq M-x describe-bindings . -.Sh COMMANDS +.Sh MG COMMANDS Commands are invoked by .Dq M-x , or by binding to a key. @@ -152,7 +275,489 @@ is the numerical argument) before the command, or by one or more invocations of the universal argument, usually bound to C-U. When invoked in this manner, the value of the numeric parameter to be passed is displayed in the minibuffer before the M-x. -.\" A complete list of commands is given in mg(5) +One common use of the parameter is in mode toggles (e.g. +make-backup-files). +If no parameter is supplied, the mode is toggled to its +alternate state. +If a positive parameter is supplied, the mode is forced to on. +Otherwise, it is forced to off. +.\" +.Bl -tag -width xxxxx +.It apropos +Help Apropos. +Prompt the user for a string, open the *help* buffer, +and list all +.Nm +commands that contain that string. +.It auto-execute +Register an auto-execute hook; that is, specify a filename pattern +(conforming to the shell's filename globbing rules) and an associated +function to execute when a file matching the specified pattern +is read into a buffer. +.It auto-fill-mode +Toggle auto-fill mode (sometimes called mail-mode), +where text inserted past the fill column is automatically wrapped +to a new line. +.It auto-indent-mode +Toggle indent mode, where identation is preserved after a newline. +.It backward-char +Move cursor backwards one character. +.It backward-kill-word +Kill text backwards by +.Va n +words. +.It backward-paragraph +Move cursor backwards +.Va n +paragraphs. +Paragraphs are delimited by <NL><NL> or <NL><TAB> or <NL><SPACE>. +.It backward-word +Move cursor backwards by the specified number of words. +.It beginning-of-buffer +Move cursor to the top of the buffer. +.It beginning-of-line +Move cursor to the beginning of the line. +.It blink-and-insert +Self-insert a character, then search backwards and blink its +matching delimeter. +For delimeters other than +parenthesis, brackets, and braces, the character itself +is used as its own match. +.It bsmap-mode +Toggle bsmap mode, where DEL and c-H are swapped. +.It call-last-kbd-macro +Invoke the keyboard macro. +.It capitalize-word +Capitalize +.Va n +words; i.e. convert the first character of the word to +upper case, and subsequent letters to lower case. +.It cd +Change the global working directory. +See also global-wd-mode. +.It copy-region-as-kill +Copy all of the characters in the region to the kill buffer, +clearing the mark afterwards. +This is a bit like a kill-region followed by a yank. +.It count-matches +Count the number of lines matching the supplied regular expression. +.It count-non-matches +Count the number of lines not matching the supplied regular expression. +.It define-key +Prompts the user for a named keymap (mode), +a key, and an mg command, then creates a keybinding in the appropriate +map. +.It delete-backward-char +Delete backwards +.Va n +characters. +Like delete-char, this actually does a kill if presented +with an argument. +.It delete-blank-lines +Delete blank lines around dot. +If dot is sitting on a blank line, this command +deletes all the blank lines above and below the current line. +Otherwise, it deletes all of the blank lines after the current line. +.It delete-char +Delete +.Va n +characters forward. +If any argument is present, it kills rather than deletes, +saving the result in the kill buffer. +.It delete-horizontal-space +Delete any whitespace around the dot. +.It delete-leading-space +Delete leading whitespace on the current line. +.It delete-trailing-space +Delete trailing whitespace on the current line. +.It delete-matching-lines +Delete all lines after dot that contain a string matching +the supplied regular expression. +.It delete-non-matching-lines +Delete all lines after dot that contain a string matching +the supplied regular expression. +.It delete-other-windows +Make the current window the only window visible on the screen. +.It delete-window +Delete current window. +.It describe-bindings +List all global and local keybindings, putting the result in +the *help* buffer. +.It describe-key-briefly +Read a key from the keyboard, and look it up in the keymap. +Display the name of the function currently bound to the key. +.It digit-argument +Process a numerical argument for keyboard-invoked functions. +.It downcase-region +Set all characters in the region to lower case. +.It downcase-word +Set characters to lower case, starting at the dot, and ending +.Va n +words away. +.It emacs-version +Return an mg version string. +.It end-kbd-macro +Stop defining a keyboard macro. +.It end-of-buffer +Move cursor to the end of the buffer. +.It end-of-line +Move cursor to the end of the line +.It enlarge-window +Enlarge the current window by shrinking either the window above +or below it. +.It eval-current-buffer +Evaluate the current buffer as a series of mg commands. +Useful for testing +.Nm +startup files. +.It eval-expression +Get one line from the user, and run it. +Useful for testing expressions in +.Nm +startup files. +.It exchange-point-and-mark +Swap the values of "dot" and "mark" in the current window. +Return an error if no mark is set. +.It execute-extended-command +Invoke an extended command; i.e. M-x. +Call the message line routine to read in the command name and apply +autocompletion to it. +When it comes back, look the name up in the symbol table and run the +command if it is found, passing arguments as necessary. +Print an error if there is anything wrong. +.It fill-paragraph +Justify a paragraph, wrapping text at the current fill column. +.It find-file +Select a file for editing. +First check if you can find the file +in another buffer; if you can find it, just switch to the buffer. +If you cannot find the file, create a new buffer, read in the +file from disk, and switch to the new buffer. +.It find-file-read-only +Same as find-file, except the new buffer is set to read-only. +.It find-alternate-file +Replace the current file with an alternate one. +Semantics for finding the replacement file are the same as +'find-file', except the current buffer is killed before the switch. +If the kill fails, or is aborted, revert to the original file. +.It find-file-other-window +Opens the specified file in a second buffer. +Splits the current window if necessary. +.It forward-char +Move cursor forwards (or backwards, if +.Va n +is negative) +.Va n +characters. +Returns an error if the end of buffer is reached. +.It forward-paragraph +Move forward +.Va n +paragraphs. +Paragraphs are delimited by <NL><NL> or <NL><TAB> or <NL><SPACE> +.It forward-word +Move the cursor forward by the specified number of words. +.It global-set-key +Bind a key in the global (fundamental) key map. +.It global-unset-key +Unbind a key from the global (fundamental) key map; i.e. set it to 'rescan' +.It global-wd-mode +Toggle global working-directory mode. +When enabled, +.Nm +defaults to opening files (and executing commands like compile and grep) +relative to the global working directory +When disabled, a working directory is set for each buffer. +.It goto-line +Go to a specific line. +If an argument is present, then +it is the line number, else prompt for a line number to use. +.It help-help +prompts for one of (a)propos, (b)indings, des(c)ribe key briefly +.It insert +Insert a string, mainly for use from macros. +.It insert-buffer +Insert the contents of another buffer at dot +.It insert-file +Insert a file into the current buffer at dot. +.It insert-with-wrap +Insert the bound character with word wrap. +Check to see if we're past the fill column, and if so, +justify this line. +.It isearch-backward +Use incremental searching, initially in the reverse direction. +isearch ignores any explicit arguments. +If invoked during macro definition or evaluation, the non-incremental +search-backward is invoked instead. +.It isearch-forward +Use incremental searching, initially in the forward direction. +isearch ignores any explicit arguments. +If invoked during macro definition or evaluation, the non-incremental +search-forward is invoked instead. +.It just-one-space +Delete any whitespace around dot, then insert a space. +.It keyboard-quit +Abort the current action. +.It kill-buffer +Dispose of a buffer, by name. +Prompt the user if the buffer +has been changed. +.It kill-line +Kill line. +If called without an argument, it kills from dot to the end +of the line, unless it is at the end of the line, when it kills the +newline. +If called with an argument of 0, it kills from the start of the +line to dot. +If called with a positive argument, it kills from dot +forward over that number of newlines. +If called with a negative argument +it kills any text before dot on the current line, then it kills back +abs(n) lines. +.It kill-paragraph +Delete +.Va n +paragraphs starting with the current one. +.It kill-region +Kill the currently defined region +.It kill-word +Delete forward +.Va n +words. +.It line-number-mode +Toggle whether line and column numbers are displayed in the modeline +.It list-buffers +Display the list of available buffers. +.It load +Prompt the user for a filename, and then execute commands +from that file. +.It local-set-key +Bind a key mapping in the local (topmost) mode. +.It local-unset-key +Unbind a key mapping in the local (topmost) mode. +.It make-backup-files +Toggle generation of backup files. +.It meta-key-mode +When disabled, the meta key can be used to insert extended-ascii (8-bit) +characters. +When enabled, the meta key acts as usual. +.It negative-argument +Process a negative argument for keyboard-invoked functions +.It newline +Insert a newline into the current buffer. +.It newline-and-indent +Insert a newline, then enough tabs and spaces to duplicate the indentation +of the previous line. +Assumes tabs are every eight characters. +.It next-line +Move forward +.Va n +lines. +.It no-tab-mode +Toggle notab mode. +In this mode, spaces are inserted rather than tabs. +.It not-modified +Turn off the modified flag in the current buffer. +.It open-line +Open up some blank space. +Essentially, insert +.Va n +newlines, then back up over them. +.It other-window +The command to make the next (down the screen) window the current +window. +There are no real errors, although the command does nothing if +there is only 1 window on the screen. +.It overwrite-mode +Toggle overwrite mode, where typing in a buffer overwrites +existing characters rather than inserting them. +.It prefix-region +Inserts a prefix string before each line of a region. +The prefix string is settable by using 'set-prefix-string'. +.It previous-line +Move backwards +.Va n +lines. +.It previous-window +This command makes the previous (up the screen) window the +current window. +There are no errors, although the command does not do +a lot if there is only 1 window. +.It push-shell +Suspend mg and switch to alternate screen, if available. +.It pwd +Display current (global) working directory in the status area. +.It query-replace +Query Replace. +Search and replace strings selectively, prompting after each match. +.It replace-string +Replace string globally without individual prompting. +.It query-replace-regexp +Replace strings selectively. +Does a search and replace operation using regular +expressions for both patterns. +.It quoted-insert +Insert the next character verbatim into the current buffer; i.e. ignore +any function bound to that key. +.It re-search-again +Perform a regular expression search again, using the same search +string and direction as the last search command. +.It re-search-backward +Search backwards using a regular expression. +Get a search string from the user, and search, starting at dot +and proceeding toward the front of the buffer. +If found dot is left +pointing at the first character of the pattern [the last character that +was matched]. +.It re-search-forward +Search forward using a regular expression. +Get a search string from the user and search for it starting at dot. +If found, move dot to just after the matched characters. +display does all +the hard stuff. +If not found, it just prints a message. +.It recenter +Reposition dot in the current window. +by default, The dot is centered. +If given a positive argument (n), the display is repositioned to line +n. +If +.Va n +is negative, it is that line from the bottom +.It redraw-display +Refresh the display. +Recomputes all window sizes in case something has changed. +.It save-buffer +Save the contents of the current buffer if it has been changed, +optionally creating a backup copy. +.It save-buffers-kill-emacs +Offer to save modified buffers and quit mg. +.It save-some-buffers +Look through the list of buffers, offering to save any buffer that +has been changed. +Buffers that are not associated with files (such +as *scratch*, *grep*, *compile*) are ignored. +.It scroll-down +Scroll backwards +.Va n +pages. +A two-line overlap between pages is +assumed. +If given a repeat argument, scrolls back lines, not pages. +.It scroll-one-line-down +Scroll the display down +.Va n +lines without changing the cursor position. +.It scroll-one-line-up +Scroll the display +.Va n +lines up without moving the cursor position +.It scroll-other-window +Scroll the next window in the window list window forward +.Va n +pages. +.It scroll-up +Scroll forward one page. +A two-line overlap between pages is +assumed. +If given a repeat argument, scrolls back lines, not pages. +.It search-again +Search again, using the same search string and direction as the last +search command. +.It search-backward +Reverse search. +Get a search string from the user, and search, starting +at dot and proceeding toward the front of the buffer. +If found, dot is +left pointing at the first character of the pattern (the last character +that was matched). +.It search-forward +Search forward. +Get a search string from the user, and search for it +starting at dot. +If found, dot gets moved to just after the matched +characters, if not found, print a message. +.It self-insert-command +Insert a character. +.It set-case-fold-search +Set case-fold searching, causing case nopt to matter +in regular expression searches. +This is the default. +.It set-default-mode +Append the supplied mode to the list of default modes +used by subsequent buffer creation. +Built in modes include: fill, indent, overwrite, and notab. +.It set-fill-column +Prompt the user for a fill column. +Used by auto-fill-mode. +.It set-mark-command +Sets the mark in the current window to the current dot location +.It set-prefix-string +Sets the prefix string to be used by the 'prefix-region' command. +.It shrink-window +Shrink current window by one line. +The window immediately below is expanded to pick up the slack. +If only one window is present, this command has no effect. +.It space-to-tabstop +Insert enough spaces to reach the next tab-stop position. +By default, tab-stops occur every 8 characters. +.It split-window-vertically +Split the current window. +A window smaller than 3 lines cannot be split. +.It start-kbd-macro +Start defining a keyboard macro. +Macro definition is ended by invoking end-kbd-macro. +.It suspend-emacs +Suspend mg and switch back to alternate screen, if in use. +.It switch-to-buffer +Prompt and switch to a new buffer in the current window. +.It switch-to-buffer-other-window +Switch to buffer in another window. +.It toggle-read-only +Toggle the read-only flag on the current buffer. +.It transpose-chars +Transpose the two characters on either side of dot. +If dot is at the end of the line transpose the two characters before it. +Return with an error if dot is at the beginning of line; + it seems to be a bit pointless to +make this work. +.It undo +Undo the most recent action. +If invoked again without an intervening command, +move the undo pointer to the previous action and undo it. +.It undo-list +Show the undo records for the current buffer in a new buffer. +.It universal-argument +Repeat the next command 4 times. +Usually bound to C-u. +This command may be stacked; e.g. +C-u C-u C-f moves the cursor forward 16 characters. +.It upcase-region +Upper case region. +Change all of the lower case characters in the region to +upper case +.It upcase-word +Move the cursor forward by the specified number of words. +As you move, convert any characters to upper case. +.It what-cursor-position +Display a bunch of useful information about the current location of +dot. +The character under the cursor (in octal), the current line, row, +and column, and approximate position of the cursor in the file (as a +percentage) is displayed. +The column position assumes an infinite +position display; it does not truncate just because the screen does. +.It write-file +Ask for a file name and write the contents of the current buffer to +that file. +Update the remembered file name and clear the buffer +changed flag. +.It yank +Yank text from kill-buffer. +Unlike emacs, the mg kill buffer consists only +of the most recent kill. +It is not a ring. +.El .Sh CONFIGURATION FILES There are two configuration files, .Pa .mg , @@ -174,9 +779,12 @@ interactive evaluation. Strings that are normally entered by the user at any subsequent prompts may be specified after the command name; e.g.: .Bd -literal -offset indent -auto-fill-mode +global-set-key ")" self-insert-command +global-set-key "\^x\^f" find-file +global-set-key "\e[Z" backward-char +set-default-mode fill set-fill-column 72 -global-set-key "\e^x\e^f" find-file +auto-execute *.c c-mode .Ed .Sh FILES .Bl -tag -width ~/.mg-TERM -compact @@ -188,12 +796,7 @@ terminal-specific startup file .Sh SEE ALSO .Xr vi 1 .Sh CAVEATS -.Nm -differs from other emacs implementations primarily in not having many -special modes for tasks other than straight editing, and in not having -special modes that support various programming languages. -.Pp -Since it is written completely in C, there is no +Since it is written completely in C, there is currently no language in which you can write extensions; however, you can rebind keys and change certain parameters. .Pp |