| MG(1) | General Commands Manual | MG(1) |
NAME
mg —
emacs-like text editor
SYNOPSIS
mg |
[-hnRsS-b
file-f
mode-u
file+line[ ]
[:column ]file ... ] |
DESCRIPTION
mg is intended to be a small, fast, and
portable editor for people who can't (or don't want to) run emacs for one
reason or another, or are not familiar with the
vi(1) editor. It is
compatible with emacs because there shouldn't be any reason to learn more
editor types than emacs or
vi(1).
This man page documents all features of mg,
but depending on how mg was built features
like cscope and
ctags(1) support may
be disabled.
The options are as follows:
- +line[:column]
- Go to the specified line, and optionally column (do not insert a space between the ‘+’ sign and the line number, or around the colon). If a negative number is specified, the line number counts backwards from the end of the file i.e. +-1 will be the last line of the file, +-2 will be second last, and so on.
-bfile- Turn on batch mode and execute the
mgcommands found in the specified file and then terminate. -fmode- Run the mode command for all buffers created from arguments on the command line, including the scratch buffer and all files.
-h- Show usage text and exit.
-n- Turn off backup file generation.
-R- Files specified on the command line will be opened read-only.
-s- Single-file mode: only the files named on the command line can be visited,
inserted, or written; anything else is refused. The startup file is not
read, backups are off as with
-n, and-band-uare refused. Combine with-Sfor the editor of a restricted shell. -S- Secure mode, for use as the editor of a restricted shell. Commands that
run other programs are disabled:
suspend-emacs,shell-command,shell-command-on-region,compile,grep,diff-buffer-with-file, all of dired, and the cscope commands. The startup file is not read and-band-uare refused. Files ending in .gz are opened as-is instead of being decompressed. -ufile- Use file as the startup file, instead of the default ~/.mg.
MINIBUFFER
Commands that need a name or a string ask for it on the bottom line, the minibuffer. The keys that move and delete in a buffer do the same there, as bound in the fundamental mode: the arrow keys, Home, End and Delete, and with Ctrl or Meta the word at a time variants. In addition, C-u and C-x delete what is before the cursor, C-w the word before it, C-k keeps the rest of the line in the kill buffer, and C-q inserts the next key as typed. Each kind of prompt keeps what was entered at it before: Up, Down, M-p and M-n walk those lines, and going back down past the newest restores what was being typed. Command names, buffer names and file names share one history each; any other prompt has its own.WINDOWS AND BUFFERS
When a file is loaded intomg, it is stored
in a buffer. This buffer may be displayed on the
screen in more than one window. At present, windows may only be split
horizontally, so each window is delineated by a modeline at the bottom. If
changes are made to a buffer, it will be reflected in all open windows.
If a file is changed outside mg and its
buffer is about to be changed, mg prompts
if the change should go ahead (y), not go ahead (n) or if the buffer should be
reverted (r) to the latest file on disk.
If a buffer name begins and ends with an asterisk, the buffer is considered
throwaway; i.e. the user will not be prompted to save changes when the buffer
is killed.
POINT AND MARK
The current cursor location inmg is called
the point (or dot).
It is possible to define a window-specific region of text by setting a second
location, called the mark. The
region is the text between point and mark
inclusive. Deleting the character at the mark position leaves the mark at the
point of deletion.
Note: The point and mark are window-specific in
mg, not buffer-specific, as in other emacs
flavours.
BACKUP FILES
Backup files have a ‘~’ character appended to the file name and are created in the current working directory by default. Whether to create backup files or not can be toggled with themake-backup-files command. The backup file
location can either be in the current working directory, or all backups can be
moved to a ~/.mg.d directory where files
retain their path name to retain uniqueness. Use the
backup-to-home-directory command to
alternate between these two locations. Further, if any application creates
backup files in /tmp, these can be left
with the leave-tmpdir-backups command.
TAGS
mg supports tag files created by
ctags(1), allowing
the user to quickly locate various object definitions. Note though that emacs
uses etags, not ctags.
CSCOPE
mg supports navigating source code using
cscope. However, mg requires cscope and
cscope-indexer executables to be present in
$PATH for it to work.
GZIP
mg is capable of opening gzipped text files,
e.g. foo.txt.gz in read-only mode. To do so
it relies on the gunzip program being
present in $PATH.
DEFAULT KEY BINDINGS
Normal editing commands are very similar to GNU Emacs. 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 the keyboard or the ALT key; otherwise ESC followed by the key X works as well. The cut, copy and paste keys of the IBM Common User Access (CUA) standard, known from the Borland DOS editors, are bound as well: Shift and an arrow key marks text, S-Delete cuts it, C-Insert copies it and S-Insert pastes. C-Delete deletes the word after dot. See CAVEATS for terminals that keep these keys for themselves.- C-@, C-SPC
- set-mark-command
- C-a, Home
- beginning-of-line
- C-b, Left
- backward-char
- C-c s c
- cscope-find-functions-calling-this-function
- C-c s d
- cscope-find-global-definition
- C-c s e
- cscope-find-egrep-pattern
- C-c s f
- cscope-find-this-file
- C-c s i
- cscope-find-files-including-file
- C-c s n
- cscope-next-symbol
- C-c s p
- cscope-prev-symbol
- C-c s s
- cscope-find-this-symbol
- C-c s t
- cscope-find-this-text-string
- C-d, Delete
- delete-char
- C-e, End
- end-of-line
- C-f, Right
- forward-char
- C-g
- keyboard-quit
- C-h C-h
- help-help
- C-h a
- apropos
- C-h b
- describe-bindings
- C-h c
- describe-key-briefly
- C-h k
- describe-key
- C-h t
- tutorial
- C-h w
- where-is
- C-h q, F1
- quick-help
- C-j
- newline-and-indent
- C-k
- kill-line
- C-l
- recenter-top-bottom
- RET
- newline
- C-n, Down
- next-line
- C-o
- open-line
- C-p, Up
- previous-line
- C-q
- quoted-insert
- C-r
- isearch-backward
- C-s
- isearch-forward
- C-t
- transpose-chars
- C-u
- universal-argument
- C-v
- scroll-up
- C-w, S-Delete
- kill-region
- C-x C-b
- list-buffers
- C-x C-c, F10
- save-buffers-kill-emacs
- C-x C-f
- find-file
- C-x C-j
- dired-jump
- C-x C-g
- keyboard-quit
- C-x C-l
- downcase-region
- C-x C-o
- delete-blank-lines
- C-x C-q
- toggle-read-only
- C-x C-r
- find-file-read-only
- C-x C-s, F2
- save-buffer
- C-x C-t
- transpose-lines
- C-x C-u
- upcase-region
- C-x C-v
- find-alternate-file
- C-x C-w
- write-file
- C-x C-x
- exchange-point-and-mark
- C-x DEL
- backward-kill-sentence
- C-x left, C-x C-left
- previous-buffer
- C-x right, C-x C-right
- next-buffer
- C-x (, F3
- start-kbd-macro
- C-x )
- end-kbd-macro
- F4
- end-or-call-last-kbd-macro
- C-x +
- balance-windows
- C-x 0
- delete-window
- C-x 1
- delete-other-windows
- C-x 2
- split-window-vertically
- C-x 3
- split-window-horizontally
- C-x SPC
- rectangle-mark-mode
- C-x 4 C-f
- find-file-other-window
- C-x 4 C-g
- keyboard-quit
- C-x 4 b
- switch-to-buffer-other-window
- C-x 4 f
- find-file-other-window
- C-x;
- set-comment-column
- C-x =
- what-cursor-position
- C-x ^
- enlarge-window
- C-x `
- next-error
- C-x b
- switch-to-buffer
- C-x d
- dired
- C-x e
- call-last-kbd-macro
- C-x f
- set-fill-column
- C-x g
- goto-line
- C-x h
- mark-whole-buffer
- C-x i
- insert-file
- C-x k
- kill-buffer
- C-x n
- other-window
- C-x o
- other-window
- C-x p
- previous-window
- C-x r SPC
- point-to-register
- C-x r c
- clear-rectangle
- C-x r d
- delete-rectangle
- C-x r i
- insert-register
- C-x r j
- jump-to-register
- C-x r k
- kill-rectangle
- C-x r M-w
- copy-rectangle-as-kill
- C-x r o
- open-rectangle
- C-x r s
- copy-to-register
- C-x r t
- string-rectangle
- C-x r y
- yank-rectangle
- C-x s
- save-some-buffers
- C-x u
- undo
- C-x {
- shrink-window-horizontally
- C-x }
- enlarge-window-horizontally
- C-y, S-Insert
- yank
- C-z
- suspend-emacs
- M-C-v
- scroll-other-window
- M-SPC
- just-one-space
- M-!
- shell-command
- M-;
- comment-dwim
- M-.
- find-tag
- M-*, M-,
- pop-tag-mark
- M-%
- query-replace
- M-<, C-Home, C-PgUp
- beginning-of-buffer
- M->, C-End, C-PgDn
- end-of-buffer
- M-\
- delete-horizontal-space
- M-^
- join-line
- M-a
- backward-sentence
- M-b, C-left
- backward-word
- M-c
- capitalize-word
- M-d, C-Delete
- kill-word
- M-e
- forward-sentence
- M-f, C-right
- forward-word
- M-g g, M-g M-g
- goto-line
- M-h
- mark-paragraph
- M-k
- kill-sentence
- M-up, M-down, M-left, M-right
- windmove-up, windmove-down, windmove-left, windmove-right
- M-S-up, M-S-down, M-S-left, M-S-right
- resize-window-up, resize-window-down, resize-window-left, resize-window-right
- S-up, S-down, S-left, S-right, S-Home, S-End
- mark text while moving
- S-PgUp, S-PgDn
- mark text by page
- C-S-up, C-S-down, C-S-left, C-S-right
- mark text by word and paragraph
- M-l
- downcase-word
- M-m
- back-to-indentation
- M-q
- fill-paragraph
- M-r
- move-to-window-line-top-bottom
- M-s
- search-forward
- M-t
- transpose-words
- M-u
- upcase-word
- M-v
- scroll-down
- M-w, C-Insert
- copy-region-as-kill
- M-x
- execute-extended-command
- M-z
- zap-to-char
- M-{, C-down
- backward-paragraph
- M-|
- shell-command-on-region
- M-}, C-up
- forward-paragraph
- M-~
- not-modified
- M-DEL
- backward-kill-word
- C-_
- undo
- )
- blink-and-insert
- DEL
- delete-backward-char
mg commands,
see MG COMMANDS. To see the
active keybindings at any time, type “M-x describe-bindings”.
MG COMMANDS
Commands are invoked by “M-x”, or by binding to a key. The names GNU Emacs binds to the same keys today work as well, for the commands that mean the same here:delete-forward-char,
delete-indentation,
flush-lines,
how-many,
keep-lines,
kill-ring-save,
kmacro-start-macro,
kmacro-end-macro,
kmacro-end-or-call-macro,
kmacro-call-macro,
move-beginning-of-line,
move-end-of-line,
read-only-mode,
save-buffers-kill-terminal,
scroll-down-command,
scroll-up-command,
split-window-below,
split-window-right,
xref-find-definitions and
xref-go-back. Many commands take an
optional numerical parameter, n. This
parameter is set either by M-<n> (where
n 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. 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.
apply-macro-to-region-lines- Applies the keyboard macro to each line in the region.
apropos- Help Apropos. Prompt the user for a string, open the *help* buffer, and
list all
mgcommands that contain that string. audible-bell- Toggle the audible system bell.
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. The pattern is tried against both the full path and the last path component, so ‘.bashrc’ matches that file in any directory. Every matching hook runs, with one exception among the built-in ones: a mode's pattern that names the file, like ‘CMakeLists.txt’, outranks the built-in patterns it only matches by wildcard, like ‘*.txt’. The hooks from the startup file run after the built-in ones, and a buffer has one major mode, so the mode a pattern of the user's names is the one the buffer gets. The settings a mode makes, such as the tab width, stay when another takes its place. Unless the user's patterns set the major mode, the text of the file may decide instead: a #! line picks the mode of its interpreter, and a file that would otherwise open inconf-modeor fundamental mode, but starts with a ‘{’ or a JSON array, opens injson-mode. auto-fill-mode- Toggle auto-fill mode (sometimes called
mail-mode) in the current buffer, where text inserted past the fill column is automatically wrapped to a new line. Can be set globally withset-default-mode. Naming it in the startup file does the same, since there is no buffer there yet to toggle it in. auto-indent-mode- Toggle indent mode in the current buffer, where indentation is preserved
after a newline. Can be set globally with
set-default-mode. Naming it in the startup file does the same, since there is no buffer there yet to toggle it in. auto-revert-mode- Toggle auto revert mode, enabled by default. While waiting for a key,
mgchecks every five seconds whether a file has changed on disk and reloads the buffer, as long as it has no unsaved edits. Each window showing the buffer keeps its line. A buffer with unsaved edits is left alone, and asks before the next edit as before.auto-revert-mode 0in the startup file disables it, andset-auto-revert-intervalchanges how often to check. auto-revert-tail-mode- Toggle tail mode in the current buffer, for following a log file like
‘
tail -f’. What is added to the file is appended to the buffer, and each window with dot at the end of the buffer follows the new end, while a window scrolled up stays where it is. Turning the mode on moves to the end of the buffer. A file that shrinks or is replaced, as when a log is rotated, is read again and shown from the end. Tail mode works withoutauto-revert-mode, on read-only buffers too, and checks as often. Everything under /var/log gets the mode automatically. To follow every log file as well:auto-execute *.log auto-revert-tail-mode back-to-indentation- Move the dot to the first non-whitespace character on the current line.
backup-to-home-directory- Save backup copies to a ~/.mg.d
directory instead of working directory. Requires
make-backup-filesto be on. backward-char- Move cursor backwards one character.
backward-kill-sentence- Kill back to the start of the sentence, n times.
backward-kill-word- Kill text backwards by n words.
backward-paragraph- Move cursor backwards n paragraphs. Paragraphs are delimited by <NL><NL> or <NL><TAB> or <NL><SPACE>.
backward-sentence- Move cursor back to the start of the sentence, or of the one before when
already there, n times. A sentence ends
with a period, question mark or exclamation mark, and any closing quotes
or brackets, followed by the end of the line or two spaces; see
sentence-end-double-space. The end of a paragraph ends one too. backward-word- Move cursor backwards by the specified number of words.
balance-windows- Even out the sizes of all windows, heights and widths alike. The quick help pop-up keeps its height.
beginning-of-buffer- Move cursor to the top of the buffer. If set, keep mark's position, otherwise set at current position. A numeric argument n will move n/10th of the way from the top.
beginning-of-line- Move cursor to the beginning of the line.
blink-and-insert- Self-insert a character, then search backwards and blink its matching
delimiter. For delimiters other than parenthesis, brackets, and braces,
the character itself is used as its own match. Can be used in the startup
file with the
global-set-keycommand. bsmap-mode- Toggle bsmap mode, where DEL and C-h are swapped. This may be needed on some systems if the backspace key doesn't work correctly.
c-mode- Toggle a KNF-compliant mode for editing C program files. TAB indents the current line, or every line in the region when the mark is active. Files named *.c and *.h get the mode automatically, as do C++ sources and headers.
call-last-kbd-macro- Invoke the keyboard macro.
capitalize-word- Capitalize n words; i.e. convert the first character of the word to upper case, and subsequent letters to lower case.
cd- Change the global working directory. See also
global-wd-mode. cmake-mode- Toggle cmake mode, which selects the cmake rules for syntax highlighting: comments, both # and #[[ ]], strings, the common commands, the upper case argument keywords like PUBLIC and REQUIRED, and ${VAR} references. Commands are recognized in lower case only. Files named CMakeLists.txt and *.cmake get the mode automatically.
column-number-mode- Toggle whether the column number is displayed in the modeline. Enabled by default.
comment-dwim- Do what a comment key should here. With the mark set, comment the region out, or back in when every line of code in it is already commented. On a line with a comment, move into it; with a numeric argument, kill the comment instead. Otherwise start a comment: after the code on the line, at the comment column, or at dot on an empty line. The delimiters come from the buffer's mode; a mode without comment syntax refuses. Bound to M-;.
comment-line- Comment the current line out, or back in when it is, and move to the next
line. With the mark set, the region, as
comment-dwimdoes. comment-region- Comment out every line of code in the region, at its indentation.
conf-mode- Toggle configuration file mode, which selects the conf rules for syntax highlighting: comments started by # or ;, or by the ! of X resources, [section] headers, the key of a key = value pair, quoted strings, numbers, and words like yes, no and off. Enabling it also sets the tab width to eight, which is what /etc is written for. Files named *.conf, *.cfg, *.ini and *.toml get the mode automatically, as do systemd units, .desktop entries, fstab, ssh_config, sshd_config, ~/.ssh/config, ~/.gitconfig, ~/.editorconfig, ~/.Xresources, ~/.Xdefaults, and the .config and *defconfig files written by kconfig.
clear-rectangle- Replace the rectangle with blanks, so the text to its right keeps its
place. A line that ends inside the rectangle loses its tail instead. See
rectangle-mark-modefor what the rectangle is. copy-rectangle-as-kill- Save the rectangle, as
kill-rectangledoes, without deleting 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-regionfollowed by ayank. copy-to-register- Save the text of the region in a register, named by the next key typed,
for
insert-register. A register holds a place or a piece of text, whichever was saved last. count-matches- Count the number of lines matching the supplied regular expression.
count-non-matches- Count the number of lines not matching the supplied regular expression.
cscope-find-this-symbol- List the matches for the given symbol.
cscope-find-global-definition- List global definitions for the given literal.
cscope-find-called-functions- List functions called from the given function.
cscope-find-functions-calling-this-function- List functions calling the given function.
cscope-find-this-text-string- List locations matching the given text string.
cscope-find-egrep-pattern- List locations matching the given extended regular expression pattern.
cscope-find-this-file- List filenames matching the given filename.
cscope-find-files-including-file- List files that #include the given filename.
cscope-next-symbol- Navigate to the next match.
cscope-prev-symbol- Navigate to the previous match.
cscope-next-file- Navigate to the next file.
cscope-prev-file- Navigate to the previous file.
cscope-create-list-of-files-to-index- Create cscope's List and Index in the given directory.
define-key- Prompts the user for a named keymap (mode), a key, and an
mgcommand, then creates a keybinding in the appropriate map. delete-backward-char- Delete backwards n characters. Like delete-char, this actually does a kill if presented with an argument.
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.
delete-char- Delete n characters forward. If any argument is present, it kills rather than deletes, saving the result in the kill buffer.
delete-duplicate-lines- Delete every line in the region that repeats an earlier line in it. The region grows to whole lines; a last line it only touches in column zero is left out.
delete-horizontal-space- Delete any whitespace around the dot.
delete-leading-space- Delete leading whitespace on the current line.
delete-trailing-space- Delete trailing whitespace on the current line.
delete-trailing-whitespace- Delete trailing whitespace on every line, and the empty lines at the end of the buffer. With the region active, only on the lines of the region.
delete-matching-lines- Delete all lines after dot that contain a string matching the supplied regular expression.
delete-non-matching-lines- Delete all lines after dot that don't contain a string matching the supplied regular expression.
delete-other-windows- Make the current window the only window visible on the screen.
delete-rectangle- Delete the rectangle without saving it.
delete-selection-mode- Toggle delete selection mode, enabled by default. When enabled, typing,
yanking, or inserting a newline with the mark active replaces the region
with the inserted text, and
delete-charordelete-backward-chardeletes the region instead of a character. The region is not saved in the kill buffer. Undo restores the region and removes the inserted text in one step. Deactivate the mark with C-g, or set it without activating it with C-SPC C-SPC, to edit next to the region instead. delete-window- Delete current window.
describe-bindings- List all global and local keybindings, putting the result in the *help* buffer.
describe-key- Read a key and show the command it runs, and every key that command is on,
in the *help* buffer. The cursor moves to the *help* window, as after
aproposanddescribe-bindings, and q there closes 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.
diff-buffer-with-file- View the differences between buffer and its associated file.
diff-mode- Toggle diff mode, which selects the diff rules for syntax highlighting:
the lines that head a file, hunk headers, and the removed and added lines
within a hunk. Lines outside a hunk are left alone, so the message of a
mailed patch keeps its own dashes. In a patch from
gitformat-patchthe mail header is colored as well, and the ‘*** SUBJECT HERE ***’ and ‘*** BLURB HERE ***’ a cover letter is created with are shown in red, so that they do not go out. Enabling it also sets the tab width to eight, which is what a diff quotes its source at. Neitherfill-paragraphnorauto-fill-modewraps a line of the diff, only the message. A cover letter opens with its ‘*** SUBJECT HERE ***’ selected, so that typing replaces it, andC-c C-nrunsdiff-next-placeholder. Files named *.diff, *.patch and *.rej get the mode automatically. diff-next-placeholder- Select the next placeholder of a cover letter from
gitformat-patch, the ‘*** SUBJECT HERE ***’ or ‘*** BLURB HERE ***’ at or after dot, with the mark at its start and dot at its end, so that typing replaces it. digit-argument- Process a numerical argument for keyboard-invoked functions.
dired-jump- Open a dired buffer containing the current buffer's directory location.
display-help-mode- Toggle permanent display of short help text in status area. By default the text is only shown at startup, until the first key press or for at most ten seconds. Keep it with “display-help-mode 1” in ~/.mg; a bare “display-help-mode” there toggles the default off.
display-line-numbers-mode- Toggle line numbers in a gutter at the left of the text. The mode belongs
to the buffer, so every window showing it gets the gutter. It is as wide
as the number of lines in the buffer needs, plus a space, and a row a long
line wraps onto is left blank. Can be set globally with
set-default-mode, or by naming it in the startup file. display-time-mode- Toggle whether the current time is displayed in the modeline. The clock is
kept current while
mgwaits for a key. downcase-region- Set all characters in the region to lower case.
downcase-word- Set characters to lower case, starting at the dot, and ending n words away.
emacs-version- Return an
mgversion string. end-kbd-macro- Stop defining a keyboard macro.
end-of-buffer- Move cursor to the end of the buffer. If set, keep mark's position, otherwise set at current position. A numeric argument n will move n/10th of the way from the end.
end-of-line- Move cursor to the end of the line.
end-or-call-last-kbd-macro- Stop defining a keyboard macro, or if macro definition is not in progress, call the last keyboard macro.
enlarge-window- Enlarge the current window by shrinking either the window above or below it.
enlarge-window-horizontally- Widen the current window by taking columns from the window beside it.
eval-current-buffer- Evaluate the current buffer as a series of
mgcommands. Useful for testingmgstartup files. eval-expression- Get one line from the user, and run it. Useful for testing expressions in
mgstartup files. exchange-point-and-mark- Swap the values of "dot" and "mark" in the current window. Return an error if no mark is set.
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.
fill-paragraph- Justify a paragraph, wrapping text at the current fill column. A list item
is filled by itself with the continuation lines aligned under its text,
and a block quote keeps its > prefix on every line. In
diff-modeandgit-commit-modethe diff is left as it is, since a fill would break it: the mail header and the diffstat of a patch, the lines that head a file, and the hunks. A paragraph ends where they begin, so the message right above the ‘---’ of a patch fills as any other. fill-region- Fill each paragraph in the region, as
fill-paragraphdoes. find-file- Select a file for editing. First check if the file can be found in another buffer; if it is there, just switch to that buffer. If the file cannot be found, create a new buffer, read in the file from disk, and switch to the new buffer.
find-file-read-only- Same as find-file, except the new buffer is set to read-only.
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.
find-file-other-window- Opens the specified file in a second buffer. Splits the current window if necessary.
find-tag- Jump to definition of tag at dot.
font-lock-mode- Toggle syntax highlighting, enabled by default. Comments, strings,
keywords, types, numbers, and preprocessor directives are colored in
buffers with a language mode, such as
c-mode. Language modes are typically enabled per file type withauto-execute. Terminals without color support show plain text. forward-char- Move cursor forwards (or backwards, if n is negative) n characters. Returns an error if the end of buffer is reached.
forward-paragraph- Move forward n paragraphs. Paragraphs are delimited by <NL><NL> or <NL><TAB> or <NL><SPACE>.
forward-sentence- Move cursor forward to the end of the sentence,
n times. See
backward-sentencefor where sentences end. forward-word- Move the cursor forward by the specified number of words.
git-commit-mode- Toggle git commit message mode, which selects the git-commit rules for
syntax highlighting: the lines git comments out below the message, the
trailers at the end of it, and the diff that
gitcommit-vappends, on the same rules asdiff-mode. It also binds the keys Magit's git-commit mode made standard, named in the echo line when the mode comes on:C-c C-c- Hand the message back to git: save the buffer and exit.
C-c C-k- Abort, after a confirmation. The buffer is emptied before it is saved,
which is how git, and
gittagandgitrebase-iwith it, are told to give up. C-c C-s- Add a Signed-off-by trailer for the committer, as read from
gitvarGIT_COMMITTER_IDENT. C-c C-a- Add an Acked-by trailer.
C-c C-r- Add a Reviewed-by trailer.
C-c C-t- Add a Tested-by trailer.
C-c C-d- Show the staged changes, running
git-commit-show-diff.
gitlogindents the message by four columns. When the mode comes on for a commit or merge message that carries no diff of its own, the staged changes, fromgitdiff--cachedin the repository of the message, are shown in a read-only *diff* window next to it: to the right when the terminal has room for both at 80 columns, else below.C-c C-drunsgit-commit-show-diffagain, after staging more from another terminal. The window is not opened in secure mode, nor when nothing is staged. A message that reads as the one of HEAD, which is whatgitcommit--amendopens, shows the whole diff of the amended commit, what is staged on top of it included; a new commit given the very message of HEAD is taken for an amend as well. Files named COMMIT_EDITMSG, MERGE_MSG, NOTES_EDITMSG, TAG_EDITMSG and git-rebase-todo get the mode automatically. global-set-key- Bind a key in the global (fundamental) key map.
global-unset-key- Unbind a key from the global (fundamental) key map; i.e. set it to 'rescan'.
global-wd-mode- Toggle global working-directory mode. When enabled,
mgdefaults 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. 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.
ido-mode- Toggle ido mode, enabled by default. When enabled, the M-x, buffer and file prompts match what is typed as a substring of the candidates, case ignored, and show the matches after the text: the selected one first, in bold and underlined, a prefix match before a substring match. RET picks the selected match, C-s and C-r, or the right and left arrow keys, select the next and previous one, TAB completes what the matches have in common or lists them, C-j takes the text as typed, and C-f at the end of the text returns to plain completion for the rest of the prompt. At a file prompt the directory is part of the prompt: RET on a subdirectory enters it, DEL with nothing typed goes to the parent, a slash in the text moves to that directory, ~/ to the home directory and // to the root, and C-d with nothing typed opens the directory in dired.
help-help- Prompts for one of (a)propos, (b)indings, des(c)ribe key briefly.
insert- Insert a string, mainly for use from macros.
insert-buffer- Insert the contents of another buffer at dot.
insert-file- Insert a file into the current buffer at dot.
insert-register- Insert the text saved in a register, named by the next key typed, at dot, which stays before the text with the mark after it, or the other way round with a prefix argument.
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.
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.
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.
join-line- Join the current line to the previous. If called with an argument, join the next line to the current one.
json-mode- Toggle json mode, which selects the json rules for syntax highlighting:
the key of a pair, told from a string by the colon after it, strings,
numbers, the words true, false and null, and the
‘
//’ and ‘/* */’ comments of JSONC, the JSON with comments of many a settings file. Those are also whatcomment-regionwrites, which strict JSON does not allow. Enabling it also sets a two column indent step in spaces, the common convention, and turns onauto-indent-mode. Files named *.json and *.jsonc get the mode automatically, as do files named *.cfg or *.conf, or for nothing in particular, whose text starts with a ‘{’ or with a [‘’ that a value follows, not a word as in an INI section. jump-to-register- Go to the place saved in a register, named by the next key typed: its buffer in the current window, then its line, or the line of the same number if that one is gone, at the same column, or the end of the line if that is shorter now.
just-one-space- Delete any whitespace around dot, then insert a space.
keyboard-quit- Abort the current action.
kill-buffer- Dispose of a buffer, by name. If the buffer name does not start and end with an asterisk, prompt the user if the buffer has been changed.
kill-current-buffer- Kill the current buffer, as
kill-bufferdoes, without asking which. 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.
kill-paragraph- Delete n paragraphs starting with the current one.
kill-rectangle- Delete the rectangle, saving its rows for
yank-rectangle, whichyankruns as well until the next ordinary kill. A line that ends inside the rectangle gives a row padded with spaces, as does a tab or a wide character crossing an edge. kill-region- Kill the currently defined region.
kill-sentence- Kill to the end of the sentence, n times.
kill-word- Delete forward n words.
leave-tmpdir-backups- Modifies the behaviour of
backup-to-home-directory. Backup files that would normally reside in /tmp are left there and not moved to the ~/.mg.d directory. line-number-mode- Toggle whether the line number is displayed in the modeline.
line-wrap-mode- Toggle line wrap mode, where a line too long for the window continues on
the rows below it instead of being truncated with a
‘
$’. The mode belongs to the buffer, so every window showing it wraps. A continued row ends with an arrow, or with a backslash outside UTF-8 locales, in a column held back from the text for it.scroll-upandscroll-downstill move by whole lines, which is more than a screenful when the lines are long. Can be set globally withset-default-mode. Naming it in the startup file does the same, since there is no buffer there yet to toggle it in. list-buffers- Display the list of available buffers. The first column in the output indicates which buffer is active with a '>' character. The second column indicates which buffers are modified. The third column indicates which buffers are read-only. The remaining columns are self-explanatory. The buffers are listed from the one used last.
load- Prompt the user for a filename, and then execute commands from that file.
local-set-key- Bind a key mapping in the local (topmost) mode.
local-unset-key- Unbind a key mapping in the local (topmost) mode.
m4-mode- Toggle m4 mode, for configure.ac and other autoconf and m4 sources, which
selects the m4 rules for syntax highlighting: dnl and # comments, the m4
builtins, every AC_, AM_, AS_, AX_, LT_, PKG_ and m4_ macro, the shell
keywords of the code between them, strings, and $variable and @VAR@
references.
comment-dwimuses dnl. Files named configure.ac, configure.in and *.m4 get the mode automatically. make-backup-files- Toggle generation of backup files. Enabled by default.
make-directory- Prompt the user for a path or directory name which is then created.
makefile-mode- Toggle makefile mode, which selects the makefile rules for syntax
highlighting: comments, strings, directives like include and ifdef,
special targets like .PHONY, and variable references, both $(VAR) and
automatic variables like $@ and $<. For automake, the if and endif of a
conditional, and the @VAR@ substitutions configure fills in, are colored
too. Enabling it also sets the tab width to eight and turns off
no-tab-mode, since recipe lines must start with a real tab. Files named Makefile, makefile, GNUmakefile, Makefile.am, Makefile.in and other Makefile.*, *.mk, and *.make, and files whose first line is a #! naming make, get the mode automatically. mark-paragraph- Mark n paragraphs.
mark-whole-buffer- Marks whole buffer as a region by putting dot at the beginning and mark at the end of buffer.
markdown-mode- Toggle markdown mode, which selects the markdown rules for syntax highlighting: headings, emphasis, inline code and fenced code blocks, links, block quotes, and list markers. Files named *.md and *.markdown get the mode automatically.
meta-key-mode- Toggle interpretation of the eighth bit of keyboard input as the Meta key. Disabled by default so that 8-bit characters can be typed. Terminals that send Meta as an escape prefix are unaffected by this setting.
move-to-window-line- Move dot to the start of the line on window row n, counted from 0 at the top, or from -1 at the bottom when n is negative. Without an argument, the middle row.
move-to-window-line-top-bottom- Move dot to the middle row of the window, and when repeated to the top
row, then the bottom one. An argument is passed to
move-to-window-line. negative-argument- Process a negative argument for keyboard-invoked functions.
newline- Insert a newline into the current buffer.
newline-and-indent- Insert a newline, then enough tabs and spaces to duplicate the indentation
of the previous line, respecting
no-tab-modeand the buffer tab width. next-history-element- At a prompt, show the line entered after the one shown, or what was being typed once past the newest. Bound to M-n; the Down arrow does the same.
next-buffer- Undo a
previous-buffer: show the buffer used after this one, walking back toward the newest. Bound to C-x right arrow and C-x C-right arrow. next-line- Move forward n lines.
no-tab-mode- Toggle notab mode. In this mode, spaces are inserted rather than tabs.
This can be set globally with
set-default-mode. Naming it in the startup file does the same, since there is no buffer there yet to toggle it in. not-modified- Turn off the modified flag in the current buffer.
open-line- Open up some blank space. Essentially, insert n newlines, then back up over them.
open-rectangle- Push the text of the rectangle right by its width, in spaces.
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.
overwrite-mode- Toggle overwrite mode in the current buffer, where typing overwrites
existing characters rather than inserting them. Can be set globally with
set-default-mode. Naming it in the startup file does the same, since there is no buffer there yet to toggle it in. prefix-region- Inserts a prefix string before each line of a region. The prefix string is
settable by using
set-prefix-stringor this command with a prefix argument. previous-history-element- At a prompt, show the line entered before the one shown. Bound to M-p; the Up arrow does the same.
previous-buffer- Show the buffer used before this one in the current window. Repeating it
walks on through the older buffers, in the order of
list-buffers, and wraps around, so holding the key visits every buffer once. Bound to C-x left arrow and C-x C-left arrow. previous-line- Move backwards n lines.
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.
point-to-register- Save where dot is, buffer and all, in a register named by the next key
typed, for
jump-to-register. A register holds a place or a piece of text, whichever was saved last. pop-tag-mark- Return to position where
find-tagwas previously invoked. push-shell- Suspend
mgand switch to alternate screen, if available. pwd- Display current (global) working directory in the status area.
python-mode- Toggle python mode, which selects the python rules for syntax
highlighting: comments, strings including the triple-quoted kind,
keywords, built-in functions, and decorators. Enabling it also sets the
tab width to four, turns on
no-tab-mode, since whitespace is structure in python and a stray tab is a syntax error, and enables the indent mode so RET keeps the indentation. TAB indents the line like the previous non-blank line, one level deeper after a line ending in a colon, or every line in the region when the mark is active. Pressing TAB again steps the line back one level at a time and wraps around, since the line may belong to any enclosing block. Files named *.py and files with a #! line naming python get the mode automatically. query-replace- Query Replace. Search and replace strings selectively, prompting after each match.
quick-help- Toggle quick help buffer.
rename-buffer- Give the current buffer a new name. A name already in use is refused; with a numeric argument, “<2>”, “<3>” and so on is added to it to make it unique.
replace-regexp- Replace regular expression globally without individual prompting.
replace-string- Replace string globally without individual prompting.
query-replace-regexp- Replace strings selectively. Does a search and replace operation using regular expressions for both patterns.
quoted-insert- Insert the next character verbatim into the current buffer; i.e. ignore any function bound to that key.
re-search-again- Perform a regular expression search again, using the same search string and direction as the last search command.
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].
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.
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 n is negative, it is that line from the bottom.
recenter-top-bottom- Center the window on dot, and when repeated put dot's line at the top,
then the bottom. An argument is passed to
recenter. rectangle-mark-mode- Toggle rectangle mark mode in the current window. The region between mark
and dot, set at dot if the mark is not active, is then the rectangle: the
lines from the one to the other, the columns from the one to the other,
drawn so and reshaped as dot moves.
C-wandM-wkill and copy the rectangle,C-dandDELdelete it,C-oopens it,C-treplaces its rows with a string, andC-x C-xgoes to the other corner. TheC-x rcommands act on the same rectangle whether the mode is on or not. Typing does not replace a rectangle. redraw-display- Refresh the display. Recomputes all window sizes in case something has changed.
resize-window-downresize-window-leftresize-window-rightresize-window-up- Move a window edge in the given direction: the edge on that side of the current window when it is a divider, otherwise the opposite one, so the arrow and the divider travel together. Bound to Meta, shift and an arrow key on terminals that send xterm or rxvt style sequences.
require-final-newline <nil|T|ask>- Require files to have a final newline added when saving. By default this
is disabled (nil). To always add a missing newline set to
T, to restore the originalmgbehavior, useask. reverse-region- Reverse the order of the lines in the region, whole lines as with
sort-lines. revert-buffer- Revert the current buffer to the latest file on disk. Each window showing the buffer keeps its line.
save-buffer- Save the contents of the current buffer if it has been changed, optionally creating a backup copy.
save-buffers-kill-emacs- Offer to save modified buffers and quit
mg. 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.
scroll-down- Scroll backwards n pages. A two-line overlap between pages is assumed. If given a repeat argument, scrolls back lines, not pages.
scroll-one-line-down- Scroll the display down n lines without changing the cursor position.
scroll-one-line-up- Scroll the display n lines up without moving the cursor position.
scroll-other-window- Scroll the next window in the window list window forward n pages.
scroll-up- Scroll forward one page. A two-line overlap between pages is assumed. If given a repeat argument, scrolls back lines, not pages.
search-again- Search again, using the same search string and direction as the last search command.
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).
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.
self-insert-command- Insert a character.
sentence-end-double-space- Toggle double or single spaces for end of sentences. Double is the
default. Affects
fill-paragraphand where the sentence commands, likeforward-sentence, find the end of a sentence. set-auto-revert-interval- Set the number of seconds between the checks made by
auto-revert-mode, five by default. set-case-fold-search- Set case-fold searching, causing case not to matter in regular expression searches. This is the default.
set-case-replace- Preserve the case of the replaced string. This is the default.
set-comment-column- Set the column a comment
comment-dwimadds after code starts in, 40 to begin with. Bound to C-x ;. set-default-mode- Append the supplied mode to the list of default modes used by subsequent buffer creation. Built in modes include: fill, indent, notab, and overwrite.
set-fill-column- Set the fill column of the current buffer, which
auto-fill-modeandfill-paragraphwrap at, to the prefix argument, or prompt for it. From the startup file it sets the default for new buffers. set-mark-command- Sets the mark in the current window to the current dot location. Typed
twice in a row, the mark is set but not activated, so the region is
neither shown nor replaced by typing. Use it for a place to return to with
exchange-point-and-mark. set-prefix-string- Sets the prefix string to be used by the
prefix-regioncommand. set-tab-width- Set the tab width for the current buffer, or the default for new buffers if called with a prefix argument or from the startup file.
shell-command- Execute external command from mini-buffer. With a universal argument (C-u), this command inserts the output into the current buffer.
shell-command-on-region- Provide the text in region to the shell command as input. With a universal argument (C-u), this command replaces the marked region with the output from the command.
shell-script-mode- Toggle shell script mode, which selects the shell rules for syntax
highlighting: comments, strings, keywords, built-in commands, and variable
references. Enabling it also sets the tab width to eight, turns off
no-tab-mode, since here documents with <<- only strip real tabs, and enables the indent mode so RET keeps the indentation of continuation lines. TAB indents the line like the previous non-blank line, or every line in the region when the mark is active; on a blank line it inserts a real tab, for here documents. Files named *.sh, *.bash, *.ksh, *.zsh, shell rc files such as .bashrc, .profile, and .zshrc, and files whose first line is a #! naming a Bourne compatible shell, get the mode automatically. Add other file types withauto-execute, for example:auto-execute .aliases shell-script-mode shift-backward-charshift-forward-charshift-next-lineshift-previous-lineshift-beginning-of-lineshift-end-of-lineshift-backward-wordshift-forward-wordshift-backward-paragraphshift-forward-paragraphshift-scroll-downshift-scroll-up- Move like the unshifted command, activating the mark at dot first, so holding shift with the arrow, Home/End, and PgUp/PgDn keys marks text, by word and paragraph with control held too. The first unshifted command drops the selection again; a mark set with C-SPC is left alone. Bound to the shifted keys on terminals that send xterm or rxvt style sequences.
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.
shrink-window-horizontally- Narrow the current window, giving the columns to the window beside it.
sort-lines- Sort the lines in the region, byte by byte as sort(1) does in the C locale; with a numeric argument in reverse. The region grows to whole lines; a last line it only touches in column zero is left out.
space-to-tabstop- Insert enough spaces to reach the next tab-stop position. By default, tab-stops occur every 8 characters.
split-window-horizontally- Split the current window side by side. The current window becomes the left
half; a window narrower than 8 columns cannot be split. Rows can only be
moved between windows of the same width, so
delete-windowandenlarge-windowrefuse layouts where that would misalign a neighbor;delete-other-windowsalways works. Side by side windows do not survive a change of terminal width. split-window-vertically- Split the current window. A window smaller than 3 lines cannot be split.
start-kbd-macro- Start defining a keyboard macro. Macro definition is ended by invoking end-kbd-macro.
string-rectangle- Replace each row of the rectangle with a string read from the minibuffer, lines that end before it padded with spaces to reach it.
suspend-emacs- Suspend
mgand switch back to alternate screen, if in use. switch-to-buffer- Prompt and switch to a new buffer in the current window.
switch-to-buffer-other-window- Switch to buffer in another window.
tabify- Turn runs of spaces in the lines of the region into tabs, where a run of a space and at least one more blank crosses a tab stop. The text stays in the same columns. The region grows to whole lines.
text-mode- Toggle text mode, for prose rather than code. Enabling it turns on
auto-fill-mode, so typing past the fill column wraps the line. Plain text has no syntax rules, so nothing is colored. Files named *.txt and *.text get the mode automatically, as do the files a source tree keeps without a suffix, AUTHORS, COPYING, INSTALL, LICENSE, NEWS, README, THANKS and TODO, and the file mutt(1) hands its editor. Add other file types withauto-execute, for example:auto-execute *.rst text-mode toggle-read-only- Toggle the read-only flag on the current buffer.
toggle-read-only-all- Toggle the read-only flag on all non-ephemeral buffers. A simple toggle that switches a global read-only flag either on or off.
transpose-chars- Transpose the two characters in front of and under dot, then move forward one character. Treat newline characters the same as any other.
transpose-lines- Exchange the line dot is on with the line above it, and move dot to the start of the next line, so repeating it drags a line down; on the first line, the first two lines are exchanged. With a numeric argument n, move the line above dot down past n lines, or up past -n; with zero, exchange the lines dot and mark are on. Bound to C-x C-t.
transpose-paragraphs- Transpose adjacent paragraphs. If multiple iterations are requested, the current paragraph will be moved n paragraphs forward.
transpose-words- Transpose adjacent words.
tutorial- Bring up
mgtutorial, if available on system. uncomment-region- Take the comment delimiters off every line of the region.
undo- Undo the most recent action. If invoked again without an intervening command, move the undo pointer to the previous action and undo it.
undo-boundary- Add an undo boundary. This is not usually done interactively.
undo-boundary-toggle- Toggle whether undo boundaries are generated. Undo boundaries are often disabled before operations that should be considered atomically undoable.
undo-enable- Toggle whether undo information is kept.
undo-list- Show the undo records for the current buffer in a new buffer.
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.
untabify- Turn the tabs in the lines of the region into the spaces that reach the same column. The region grows to whole lines.
upcase-region- Upper case region. Change all of the lower case characters in the region to upper case.
upcase-word- Move the cursor forward by the specified number of words. As it moves, convert any characters to upper case.
use-short-answers- Toggle accepting a single y or n in place of a spelled out yes or no answer to important questions. Enabled by default, unlike GNU Emacs.
visible-bell- Toggle the visible bell. If this toggle is on, the modeline will flash.
visit-tags-table- Load tags file to be used for subsequent find-tag.
visual-mark-mode- Toggle visual mark mode, enabled by default. When enabled, the region
between mark and dot is drawn in reverse video after
set-mark-command,mark-whole-buffer,mark-paragraph, andexchange-point-and-mark. The highlight is removed when the buffer is modified, the command is aborted with C-g, or the region is copied. 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.
where-is- Prompt for a command and show the keys it is on.
whitespace-cleanup- Clean up whitespace in the buffer: delete trailing whitespace on every
line and empty lines at the start and end of the buffer, and redo the
indentation of each line with tabs and spaces, or with spaces alone in
no-tab-mode, at the buffer's tab width. With the mark set, only the lines of the region are cleaned, and their empty lines are kept. windmove-downwindmove-leftwindmove-rightwindmove-up- Select the window beside the current one in the given direction. With several neighbors the topmost, or leftmost, is chosen. Bound to Meta and an arrow key on terminals that send xterm or rxvt style sequences; note that some terminals grab these keys for their own split panes.
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.
yaml-mode- Toggle yaml mode, which selects the yaml rules for syntax highlighting:
comments, the ‘
---’ and ‘...’ document markers, list markers, the key of a key: value pair, quoted strings, numbers, the words YAML reads as booleans and null, and anchors and aliases. A block scalar introduced by ‘|’ or ‘>’ takes the lines below it, which are left as text, so a shell script under ‘run: |’ is not read as YAML. A plain scalar is left alone, there being no way to tell one from prose. Enabling it also sets a two column tab width, turns onno-tab-mode, since a tab is a syntax error in YAML, and enables the indent mode so RET keeps the indentation. Files named *.yml and *.yaml get the mode automatically, as do .clang-format and .yamllint. yank- Yank text from kill-buffer. Unlike emacs, the
mgkill buffer consists only of the most recent kill. It is not a ring. yank-rectangle- Insert the rectangle last killed or copied with its top left corner at dot, a row to a line, lines padded with spaces to reach the column and added at the end of the buffer as needed. The mark goes to the corner, dot after the last row.
zap-to-char- Ask for a character and delete text from the current cursor position until the next instance of that character, including it.
zap-up-to-char- Like zap-to-char but doesn't delete the target character.
MG DIRED KEY BINDINGS
Specific key bindings are available in dired mode.- DEL
- dired-unmark-backward
- RET, e, f and C-m
- dired-find-file
- SPC, n
- dired-next-line
- !
- dired-shell-command
- +
- dired-create-directory
- ^
- dired-up-directory
- a
- dired-find-alternate-file
- c
- dired-do-copy
- d and C-d
- dired-flag-file-deletion
- g
- dired-revert
- j
- dired-goto-file
- o
- dired-find-file-other-window
- p
- dired-previous-line
- q
- quit-window
- r
- dired-do-rename
- u
- dired-unmark
- x
- dired-do-flagged-delete
- C-v
- dired-scroll-down
- M-v
- dired-scroll-up
MG DIRED COMMANDS
The following are a list of the commands specific to dired mode:dired-create-directory- Create a directory.
dired-do-copy- Copy the file listed on the current line of the dired buffer.
dired-do-flagged-delete- Delete the files that have been flagged for deletion.
dired-do-rename- Rename the file listed on the current line of the dired buffer.
dired-find-alternate-file- Replace the current dired buffer with an alternate one as specified by the position of the cursor in the dired buffer.
dired-find-file- Open the file on the current line of the dired buffer. If the cursor is on a directory it will be opened in dired mode.
dired-flag-file-deletion- Flag the file listed on the current line for deletion. This is indicated
in the buffer by putting a D at the left margin. No files are actually
deleted until the function
dired-do-flagged-deleteis executed. dired-find-file-other-window- Open the file on the current line of the dired buffer in a different window.
dired-goto-file- Move the cursor to a file name in the dired buffer.
dired-next-line- Move the cursor to the next line.
dired-other-window- This function works just like dired, except that it puts the dired buffer in another window.
dired-previous-line- Move the cursor to the previous line.
dired-revert- Refresh the dired buffer while retaining any flags.
dired-scroll-down- Scroll down the dired buffer.
dired-scroll-up- Scroll up the dired buffer.
dired-shell-command- Pipe the file under the current cursor position through a shell command.
dired-unmark- Remove the deletion flag for the file on the current line.
dired-unmark-backward- Remove the deletion flag from the file listed on the previous line of the dired buffer, then move up to that line.
dired-up-directory- Open a dired buffer in the parent directory.
quit-window- Close the current dired buffer.
CONFIGURATION FILES
There are two configuration files, .mg and .mg-$TERM. Here,$TERM represents the name of the terminal
type; e.g. if the terminal type is set to “vt100”,
mg will use
.mg-vt100 as a startup file. The terminal
type startup file is used first.
The startup file format is a list of commands, one per line, as used for
interactive evaluation. Strings that are normally entered by the user at any
subsequent prompts may be specified after the command name; e.g.:
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 auto-execute *.c c-mode
ENVIRONMENT
MGSECURE- When set, in the manner of
LESSSECURE,mgruns in secure mode as if started with-S.
FILES
- ~/.mg
- normal startup file
- ~/.mg-$TERM
- terminal-specific startup file
- ~/.mg.d
- alternative backup file location
- /usr/share/doc/mg/tutorial
- concise tutorial
SEE ALSO
ctags(1), vi(1)CAVEATS
Since it is written completely in C, there is currently no language in which extensions can be written; however, keys can be rebound and certain parameters can be changed in startup files. On terminals that signal the Meta key by setting the eighth bit, Meta bindings only work after enablingmeta-key-mode.
Most terminal emulators act on S-Insert themselves, pasting the system
selection, and some do the same with C-Insert for copy. Those keys never reach
mg unless the terminal is told to pass them
on. C-Insert and C-Delete also need a terminal that sends xterm or rxvt style
sequences for them.
rxvt and urxvt keep S-PgUp and S-PgDn for their scrollback. They also send the
same for control, shift and an arrow key as for shift and the arrow alone, so
marking by word and paragraph only works with keysym resources that make them
send the xterm sequences.
In UTF-8 locales, multibyte characters are edited and displayed as single
characters. Double-width characters occupy two columns, but combining
characters still render incorrectly. Case conversion and case-insensitive
search fold only ASCII in UTF-8 locales, and mini-buffer editing still works
on bytes.| October 21, 2026 | Debian |
Maintained in troglobit/mg as doc/mg.1. Send corrections there, or read it on the mirror.