MG(1)

๐ŸŒธ MG(1) ๐ŸŒธ

okay bestie, so this is the manual page for mg, and yes it's a General Commands Manual page, because it's a real manual. sit down, grab a strawberry drink ๐Ÿ“, we're doing this.


โœจ NAME โœจ

mg โ€” the emacs-like text editor. that's it. that's the name. iconic. ๐Ÿ’…


โœจ SYNOPSIS โœจ

mg [-hnR] [-b file] [-f mode] [-u file] [+number] [file ...]

literally just vibes and flags, we'll get to each one ๐Ÿซถ


๐Ÿ’– DESCRIPTION ๐Ÿ’–

so mg is designed to be a small, fast, and portable editor for people who can't (or honestly just don't want to) run emacs for one reason or another, or who aren't familiar with vi(1). it's compatible with emacs because โ€” and I quote the vibes here โ€” there shouldn't be any reason to learn more editor types than emacs or vi(1). periodt. no cap. ๐Ÿ‘‘

this man page documents all the features of mg, but heads up: depending on how mg was built, features like cscope and ctags(1) support may be disabled. so like, don't come for me if your build said no ๐Ÿ™ˆ

the options are as follows:

  • +number โ€” go to the line specified by number (and do not insert a space between the โ€˜+โ€™ sign and the number, bestie, I'm begging). 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. counting backwards is lowkey a flex โœจ
  • -b file โ€” turn on batch mode and execute the mg commands found in the specified file and then terminate. it does the thing and dips ๐Ÿ’จ
  • -f mode โ€” run the mode command for all buffers created from arguments on the command line, including the scratch buffer and all files. all of them. every single one ๐Ÿซถ
  • -h โ€” show usage text and exit. the polite little "here's how to use me" ๐ŸŽ€
  • -n โ€” turn off backup file generation.
  • -R โ€” files specified on the command line will be opened read-only. look, don't touch ๐Ÿ”’
  • -u file โ€” use file as the startup file, instead of the default ~/.mg.

๐ŸชŸ WINDOWS AND BUFFERS ๐ŸชŸ

when a file is loaded into mg, it's 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. and if changes are made to a buffer, it will be reflected in all open windows. yes, all of them, they're all in the group chat ๐Ÿ’ฌ

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. a little vibe check before the chaos ๐ŸŒˆ

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. it's giving disposable camera energy ๐Ÿ“ธ


๐Ÿ“ POINT AND MARK ๐Ÿ“

the current cursor location in mg is called the point (or dot). it's 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. tiny detail, huge consequences ๐Ÿ’…

Note: the point and mark are window-specific in mg, not buffer-specific, as in other emacs flavours. this is the main character difference, iykyk โœจ

๐Ÿ’พ 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 the make-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 there with the leave-tmpdir-backups command. bye to /tmp clutter, we don't know her ๐Ÿฆ‹


๐Ÿท๏ธ 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. don't mix them up, they will notice ๐Ÿ‘€


๐Ÿ” CSCOPE ๐Ÿ”

mg supports navigating source code using cscope. however, mg requires the cscope and cscope-indexer executables to be present in $PATH for it to work. no executables, no navigation. that's the deal ๐Ÿค


๐Ÿ—œ๏ธ 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. compressed and cute, but don't try to write to it ๐Ÿงš


โŒจ๏ธ 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. three ways to do one thing? slay ๐ŸŒˆ

  • 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 t โ€” tutorial
  • C-h q โ€” quick-help
  • C-j โ€” newline-and-indent
  • C-k โ€” kill-line
  • C-l โ€” recenter
  • 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 โ€” kill-region
  • C-x C-b โ€” list-buffers
  • C-x C-c โ€” 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 โ€” save-buffer
  • 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 ( โ€” start-kbd-macro
  • C-x ) โ€” end-kbd-macro
  • C-x 0 โ€” delete-window
  • C-x 1 โ€” delete-other-windows
  • C-x 2 โ€” split-window-vertically
  • 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 = โ€” 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 s โ€” save-some-buffers
  • C-x u โ€” undo
  • C-y โ€” yank
  • C-z โ€” suspend-emacs
  • M-C-v โ€” scroll-other-window
  • M-SPC โ€” just-one-space
  • M-! โ€” shell-command
  • M-. โ€” find-tag
  • M-*, M-, โ€” pop-tag-mark
  • M-% โ€” query-replace
  • M-<, C-PgUp โ€” beginning-of-buffer
  • M->, C-PgDn โ€” end-of-buffer
  • M-\ โ€” delete-horizontal-space
  • M-^ โ€” join-line
  • M-b, C-left, M-left โ€” backward-word
  • M-c โ€” capitalize-word
  • M-d โ€” kill-word
  • M-f, C-right, M-right โ€” forward-word
  • M-h โ€” mark-paragraph
  • M-l โ€” downcase-word
  • M-m โ€” back-to-indentation
  • M-q โ€” fill-paragraph
  • M-r โ€” search-backward
  • M-s โ€” search-forward
  • M-t โ€” transpose-words
  • M-u โ€” upcase-word
  • M-v โ€” scroll-down
  • M-w โ€” 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

for a complete description of mg commands, see โ€œMG COMMANDSโ€. to see the active keybindings at any time, type M-x describe-bindings. go look at your own keybinds, it's self-care ๐Ÿ’…


๐Ÿ‘‘ MG COMMANDS ๐Ÿ‘‘

commands are invoked by โ€œM-xโ€, or by binding to a key. 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. that's the whole ruleset, bestie ๐ŸŽ€

  • apply-macro-to-region-lines โ€” applies the keyboard macro to each line in the region. every line gets the treatment โœจ
  • apropos โ€” Help Apropos. prompt the user for a string, open the *help* buffer, and list all mg commands that contain that string. search but make it cute ๐Ÿ”
  • audible-bell โ€” toggle the audible system bell. beep or no beep, your call ๐Ÿ””
  • 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. pattern matched โ†’ function runs, automatic ๐Ÿ’ซ
  • 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 with set-default-mode. no more scroll-forever lines ๐ŸŒธ
  • 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. your indentation stays exactly where you left it ๐Ÿซถ
  • back-to-indentation โ€” move the dot to the first non-whitespace character on the current line. skip the spaces, get to the point ๐Ÿ“
  • backup-to-home-directory โ€” save backup copies to a ~/.mg.d directory instead of working directory. requires make-backup-files to be on. home for backups, home for us ๐Ÿ 
  • backward-char โ€” move cursor backwards one character. tiny step back โฌ…๏ธ
  • backward-kill-word โ€” kill text backwards by n words. yeet, but in reverse ๐Ÿ’€
  • backward-paragraph โ€” move cursor backwards n paragraphs. paragraphs are delimited by <NL><NL> or <NL><TAB> or <NL><SPACE>. yes, those three, exact. don't argue with the delimiters ๐Ÿ˜ค
  • backward-word โ€” Moves the cursor backwards by the specified number of words. ๐Ÿ’…
  • beginning-of-buffer โ€” Jumps the cursor to the top of the buffer. If set, it keeps the markโ€™s position; otherwise it sets the mark at the current position. A numeric argument n will move n/10th of the way from the top. โœจ
  • beginning-of-line โ€” Moves the cursor to the beginning of the line. Simple, iconic, does exactly what it says. ๐ŸŽ€
  • blink-and-insert โ€” Self-inserts a character, then searches backwards and blinks 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-key command. ๐Ÿฆ‹
  • bsmap-mode โ€” Toggles 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 โ€” Toggles a KNF-compliant mode for editing C program files. C girlies stay winning. ๐Ÿ’–
  • call-last-kbd-macro โ€” Invokes the keyboard macro. Replay era, no cap. ๐Ÿ”ฅ
  • capitalize-word โ€” Capitalizes n words; i.e. converts the first character of the word to upper case, and subsequent letters to lower case. โœจ
  • cd โ€” Changes the global working directory. See also global-wd-mode. ๐Ÿ“
  • column-number-mode โ€” Toggles whether the column number is displayed in the modeline. Enabled by default. ๐Ÿ’…
  • copy-region-as-kill โ€” Copies 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. ๐ŸŽ€
  • count-matches โ€” Counts the number of lines matching the supplied regular expression. Math but make it text. ๐Ÿ”ข
  • count-non-matches โ€” Counts the number of lines not matching the supplied regular expression. The hater counter. ๐Ÿ™ˆ
  • cscope-find-this-symbol โ€” Lists the matches for the given symbol. ๐Ÿ”Ž
  • cscope-find-global-definition โ€” Lists global definitions for the given literal. ๐ŸŒˆ
  • cscope-find-called-functions โ€” Lists functions called from the given function. ๐Ÿ“ž
  • cscope-find-functions-calling-this-function โ€” Lists functions calling the given function. The callers have been identified. ๐Ÿ‘€
  • cscope-find-this-text-string โ€” Lists locations matching the given text string. ๐Ÿงต
  • cscope-find-egrep-pattern โ€” Lists locations matching the given extended regular expression pattern. Regex bestie behavior. โœจ
  • cscope-find-this-file โ€” Lists filenames matching the given filename. ๐Ÿ—‚๏ธ
  • cscope-find-files-including-file โ€” Lists files that #include the given filename. Include-girlie lore. ๐Ÿ“š
  • cscope-next-symbol โ€” Navigates to the next match. โญ๏ธ
  • cscope-prev-symbol โ€” Navigates to the previous match. โฎ๏ธ
  • cscope-next-file โ€” Navigates to the next file. ๐Ÿฆ‹
  • cscope-prev-file โ€” Navigates to the previous file. ๐ŸŽ€
  • cscope-create-list-of-files-to-index โ€” Creates cscopeโ€™s List and Index in the given directory. ๐Ÿ’…
  • define-key โ€” Prompts the user for a named keymap (mode), a key, and an mg command, then creates a keybinding in the appropriate map. Customization slay. ๐Ÿ› ๏ธ
  • delete-backward-char โ€” Deletes backwards n characters. Like delete-char, this actually does a kill if presented with an argument. ๐Ÿ’€
  • delete-blank-lines โ€” Deletes 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 โ€” Deletes n characters forward. If any argument is present, it kills rather than deletes, saving the result in the kill buffer. ๐Ÿ˜ญ
  • delete-horizontal-space โ€” Deletes any whitespace around the dot. Space cleanup era. ๐Ÿงน
  • delete-leading-space โ€” Deletes leading whitespace on the current line. ๐ŸŽ€
  • delete-trailing-space โ€” Deletes trailing whitespace on the current line. Goodbye invisible mess. โœจ
  • delete-matching-lines โ€” Deletes all lines after dot that contain a string matching the supplied regular expression. ๐Ÿšฎ
  • delete-non-matching-lines โ€” Deletes all lines after dot that donโ€™t contain a string matching the supplied regular expression. The reverse filter, periodt. ๐Ÿ’…
  • delete-other-windows โ€” Makes the current window the only window visible on the screen. Main character window energy. ๐Ÿ‘‘
  • delete-window โ€” Deletes the current window. ๐ŸชŸ
  • describe-bindings โ€” Lists all global and local keybindings, putting the result in the *help* buffer. The keybinding encyclopedia. ๐Ÿ“–
  • describe-key-briefly โ€” Reads a key from the keyboard, and looks it up in the keymap. Displays the name of the function currently bound to the key. ๐Ÿ”‘
  • diff-buffer-with-file โ€” Views the differences between the buffer and its associated file. Spot the difference, bestie. ๐Ÿ•ต๏ธ
  • digit-argument โ€” Processes a numerical argument for keyboard-invoked functions. Numbers before commands, iykyk. ๐Ÿ”ข
  • dired-jump โ€” Opens a dired buffer containing the current bufferโ€™s directory location. ๐Ÿ“‚
  • display-help-mode โ€” Toggles permanent display of short help text in the status area. Enabled by default. ๐Ÿซถ
  • display-time-mode โ€” Toggles whether the current time is displayed in the modeline. Clock check. โฐ
  • downcase-region โ€” Sets all characters in the region to lower case. lowercase era. ๐Ÿ“
  • downcase-word โ€” Sets characters to lower case, starting at the dot, and ending n words away. โœจ
  • emacs-version โ€” Returns an mg version string. Identity moment. ๐Ÿ’–
  • end-kbd-macro โ€” Stops defining a keyboard macro. Thatโ€™s a wrap. ๐ŸŽฌ
  • end-of-buffer โ€” Moves the cursor to the end of the buffer. If set, it keeps the markโ€™s position; otherwise it sets the mark at the current position. A numeric argument n will move n/10th of the way from the end. ๐ŸŒ™
  • end-of-line โ€” Moves the cursor to the end of the line. ๐ŸŽ€
  • end-or-call-last-kbd-macro โ€” Stops defining a keyboard macro, or if macro definition is not in progress, calls the last keyboard macro. Multitasking icon. ๐Ÿ’…
  • enlarge-window โ€” Enlarges the current window by shrinking either the window above or below it. Window gains, neighbor loses. ๐Ÿ˜ญ
  • eval-current-buffer โ€” Evaluates the current buffer as a series of mg commands. Useful for testing mg startup files. ๐Ÿงช
  • eval-expression โ€” Gets one line from the user, and runs it. Useful for testing expressions in mg startup files. โœจ
  • exchange-point-and-mark โ€” Swaps the values of "dot" and "mark" in the current window. Returns an error if no mark is set. ๐Ÿ”„
  • execute-extended-command โ€” Invokes an extended command; i.e. M-x. Calls the message line routine to read in the command name and apply autocompletion to it. When it comes back, looks the name up in the symbol table and runs the command if it is found, passing arguments as necessary. Prints an error if there is anything wrong. ๐Ÿซก
  • fill-paragraph โ€” Justifies a paragraph, wrapping text at the current fill column. Formatting slay. ๐Ÿ“
  • find-file โ€” Selects a file for editing. First checks if the file can be found in another buffer; if itโ€™s there, just switches to that buffer. If the file cannot be found, creates a new buffer, reads in the file from disk, and switches to the new buffer. ๐Ÿ“‚
  • find-file-read-only โ€” Same as find-file, except the new buffer is set to read-only. Look, donโ€™t touch. ๐Ÿ‘€
  • find-alternate-file โ€” Replaces 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, it reverts to the original file. ๐Ÿ”
  • find-file-other-window โ€” Opens the specified file in a second buffer. Splits the current window if necessary. ๐ŸชŸ
  • find-tag โ€” Jumps to the definition of the tag at dot. Tag jump scare but helpful. ๐Ÿท๏ธ
  • forward-char โ€” Moves the cursor forwards (or backwards, if n is negative) n characters. Returns an error if the end of buffer is reached. ๐Ÿšถ
  • forward-paragraph โ€” Moves forward n paragraphs. Paragraphs are delimited by <NL><NL> or <NL><TAB> or <NL><SPACE>. ๐Ÿ“„
  • forward-word โ€” Moves the cursor forward by the specified number of words. ๐Ÿฆ‹
  • global-set-key โ€” Binds a key in the global (fundamental) key map. Global keybinding era. ๐ŸŒ
  • global-unset-key โ€” Unbinds a key from the global (fundamental) key map; i.e. sets it to 'rescan'. ๐Ÿšซ
  • global-wd-mode โ€” Toggles global working-directory mode. When enabled, mg 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. ๐Ÿ“
  • goto-line โ€” Goes to a specific line. If an argument is present, then it is the line number; else prompt for a line number to use. ๐Ÿ“
  • help-help โ€” Prompts for one of (a)propos, (b)indings, des(c)ribe key briefly. Helpception. ๐Ÿ†˜
  • insert โ€” Inserts a string, mainly for use from macros. ๐Ÿงต
  • insert-buffer โ€” Inserts the contents of another buffer at dot. ๐Ÿ“ฅ
  • insert-file โ€” Inserts a file into the current buffer at dot. ๐Ÿ“„
  • insert-with-wrap โ€” Inserts the bound character with word wrap. Checks to see if weโ€™re past the fill column, and if so, justifies this line. ๐ŸŽ€
  • isearch-backward โ€” Uses 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 โ€” Uses 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 โ€” Joins the current line to the previous. If called with an argument, joins the next line to the current one. ๐Ÿงฒ
  • just-one-space โ€” Deletes any whitespace around dot, then inserts a space. Exactly one. No notes. ๐Ÿ’…
  • keyboard-quit โ€” Aborts the current action. Emergency exit bestie. ๐Ÿšช
  • kill-buffer โ€” Disposes of a buffer, by name. If the buffer name does not start and end with an asterisk, prompts the user if the buffer has been changed. ๐Ÿ’€
  • kill-line โ€” Kills the 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 โ€” Deletes n paragraphs starting with the current one. ๐Ÿ“๐Ÿ’€
  • kill-region โ€” Kills the currently defined region. ๐ŸŽฏ
  • kill-word โ€” Deletes forward n words. โœ‚๏ธ
  • leave-tmpdir-backups โ€” okay so this one changes how backup-to-home-directory behaves ๐Ÿ’… Backup files that would normally live in /tmp get left right there and are not moved into the ~/.mg.d directory. No cap.
  • line-number-mode โ€” toggles whether the line number shows up in the modeline โœจ
  • list-buffers โ€” shows you the list of available buffers ๐ŸŽ€ The first column marks which buffer is active with a '>' character, the second column marks which buffers are modified, and the third column marks which buffers are read-only. The remaining columns are self-explanatory, bestie.
  • load โ€” prompts you for a filename, then executes commands from that file ๐Ÿ’–
  • local-set-key โ€” binds a key mapping in the local (topmost) mode ๐ŸŒธ
  • local-unset-key โ€” unbinds a key mapping in the local (topmost) mode ๐Ÿฆ‹
  • make-backup-files โ€” toggles generation of backup files. Enabled by default ๐Ÿ”ฅ
  • make-directory โ€” prompts you for a path or directory name, and then it gets created โœจ
  • mark-paragraph โ€” marks n paragraphs ๐ŸŽ€
  • mark-whole-buffer โ€” marks the whole buffer as a region by putting dot at the beginning and mark at the end of the buffer ๐Ÿ‘‘
  • 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.
  • negative-argument โ€” processes a negative argument for keyboard-invoked functions ๐Ÿ’…
  • newline โ€” inserts a newline into the current buffer ๐ŸŒˆ
  • newline-and-indent โ€” inserts a newline, then enough tabs and spaces to duplicate the indentation of the previous line, respecting no-tab-mode and the buffer tab width โญ
  • next-line โ€” moves forward n lines ๐Ÿซถ
  • no-tab-mode โ€” toggles notab mode ๐Ÿฆ‹ In this mode, spaces are inserted rather than tabs. This can be set globally with set-default-mode.
  • not-modified โ€” turns off the modified flag in the current buffer ๐Ÿ’œ
  • open-line โ€” opens up some blank space. Essentially, insert n newlines, then back up over them ๐Ÿ™ˆ
  • other-window โ€” makes 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 โ€” toggles overwrite mode in the current buffer, where typing overwrites existing characters rather than inserting them ๐Ÿ˜ญ Can be set globally with set-default-mode.
  • prefix-region โ€” inserts a prefix string before each line of a region ๐ŸŒธ The prefix string is settable by using set-prefix-string or this command with a prefix argument.
  • previous-line โ€” moves backwards n lines โœจ
  • previous-window โ€” 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.
  • pop-tag-mark โ€” returns to the position where find-tag was previously invoked ๐Ÿ‘‘
  • push-shell โ€” suspends mg and switches to the alternate screen, if available ๐Ÿ’…
  • pwd โ€” displays the current (global) working directory in the status area ๐ŸŒˆ
  • query-replace โ€” Query Replace. Searches and replaces strings selectively, prompting after each match โญ
  • quick-help โ€” toggles the quick help buffer ๐Ÿฆ‹
  • replace-regexp โ€” replaces a regular expression globally without individual prompting ๐Ÿ”ฅ
  • replace-string โ€” replaces a string globally without individual prompting ๐Ÿ’–
  • query-replace-regexp โ€” replaces strings selectively. Does a search and replace operation using regular expressions for both patterns ๐ŸŒธ
  • quoted-insert โ€” inserts the next character verbatim into the current buffer; i.e. ignore any function bound to that key ๐Ÿ™ˆ
  • re-search-again โ€” performs a regular expression search again, using the same search string and direction as the last search command โœจ
  • re-search-backward โ€” searches backwards using a regular expression ๐ŸŽ€ Gets a search string from the user, and searches, 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 โ€” searches forward using a regular expression ๐Ÿ’… Gets a search string from the user and searches for it starting at dot. If found, moves dot to just after the matched characters. display does all the hard stuff. If not found, it just prints a message.
  • recenter โ€” repositions 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.
  • redraw-display โ€” refreshes the display โญ Recomputes all window sizes in case something has changed.
  • revert-buffer โ€” reverts the current buffer to the latest file on disk ๐Ÿซถ
  • save-buffer โ€” saves the contents of the current buffer if it has been changed, optionally creating a backup copy ๐Ÿ’–
  • save-buffers-kill-emacs โ€” offers to save modified buffers and quit mg ๐Ÿ˜ญ
  • save-some-buffers โ€” looks 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 โ€” scrolls 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 โ€” scrolls the display down n lines without changing the cursor position โœจ
  • scroll-one-line-up โ€” scrolls the display n lines up without moving the cursor position ๐Ÿฆ‹
  • scroll-other-window โ€” scrolls the next window in the window list window forward n pages ๐Ÿ‘‘
  • scroll-up โ€” scrolls forward one page ๐Ÿ’… A two-line overlap between pages is assumed. If given a repeat argument, scrolls back lines, not pages.
  • search-again โ€” searches again, using the same search string and direction as the last search command ๐ŸŒˆ
  • search-backward โ€” Reverse search โญ Gets a search string from the user, and searches, 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 ๐Ÿ’– Gets a search string from the user, and searches 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 โ€” inserts a character ๐ŸŽ€
  • sentence-end-double-space โ€” toggles double or single spaces for end of sentences ๐ŸŒธ Double is the default. Currently only affects fill-paragraph.
  • set-case-fold-search โ€” sets case-fold searching, causing case not to matter in regular expression searches โœจ This is the default.
  • set-case-replace โ€” preserves the case of the replaced string ๐Ÿฆ‹ This is the default.
  • set-default-mode โ€” appends 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 โ€” prompts the user for a fill column ๐Ÿ’… Used by auto-fill-mode.
  • set-mark-command โ€” sets the mark in the current window to the current dot location ๐ŸŒˆ
  • set-prefix-string โ€” sets the prefix string to be used by the prefix-region command โญ
  • set-tab-width โ€” sets 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 โ€” executes an external command from the mini-buffer ๐Ÿซถ
  • shell-command-on-region โ€” provides the text in region to the shell command as input ๐ŸŽ€
  • shrink-window โ€” shrinks the 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.
  • split-window-vertically โ€” splits the current window โœจ A window smaller than 3 lines cannot be split.
  • start-kbd-macro โ€” starts defining a keyboard macro ๐Ÿฆ‹ Macro definition is ended by invoking end-kbd-macro.
  • suspend-emacs โ€” suspends mg and switches back to the alternate screen, if in use ๐Ÿ‘‘
  • switch-to-buffer โ€” prompts and switches to a new buffer in the current window ๐Ÿ’…
  • switch-to-buffer-other-window โ€” switches to buffer in another window ๐ŸŒˆ
  • toggle-read-only โ€” toggles the read-only flag on the current buffer โญ
  • toggle-read-only-all โ€” toggles 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 โ€” transposes the two characters in front of and under dot, then moves forward one character ๐ŸŽ€ Treat newline characters the same as any other.
  • transpose-paragraphs โ€” transposes adjacent paragraphs ๐ŸŒธ If multiple iterations are requested, the current paragraph will be moved n paragraphs forward.
  • transpose-words โ€” transposes adjacent words โœจ
  • tutorial โ€” brings up the mg tutorial, if available on system ๐Ÿฆ‹
  • undo โ€” undoes the most recent action ๐Ÿ‘‘ If invoked again without an intervening command, moves the undo pointer to the previous action and undoes it.
  • undo-boundary โ€” adds an undo boundary ๐Ÿ’… This is not usually done interactively.
  • undo-boundary-toggle โ€” toggles whether undo boundaries are generated ๐ŸŒˆ Undo boundaries are often disabled before operations that should be considered atomically undoable.
  • undo-enable โ€” toggles whether undo information is kept โญ
  • undo-list โ€” shows the undo records for the current buffer in a new buffer ๐Ÿ’–
  • universal-argument โ€” repeats 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.
  • upcase-region โ€” Upper case region ๐ŸŽ€ Changes all of the lower case characters in the region to upper case.
  • upcase-word โ€” moves the cursor forward by the specified number of words ๐ŸŒธ As it moves, converts any characters to upper case.
  • visible-bell โ€” toggles the visible bell โœจ If this toggle is on, the modeline will flash.
  • visit-tags-table โ€” loads the tags file to be used for subsequent find-tag ๐Ÿฆ‹
  • what-cursor-position โ€” bestie this one is the โœจinfo dumpโœจ command. It tells you literally everything about where dot is right now: the character under the cursor (in octal, because of course), the current line, row, and column, and roughly where you are in the file as a percentage. And yes, the column position assumes an infinite position display โ€” it does not truncate just because your screen does ๐Ÿซถ
  • write-file โ€” asks you for a file name and writes the contents of the current buffer into that file. Then it updates the remembered file name and clears the buffer changed flag. Fresh start energy ๐Ÿ’…
  • yank โ€” pulls text out of the kill-buffer. But heads up: unlike emacs, the mg kill buffer consists only of the most recent kill. It is not a ring. No scrolling back through your history, sorry bestie ๐Ÿ˜ญ
  • zap-to-char โ€” asks for a character, then deletes text from the current cursor position up to and including the next instance of that character. Gone. Deleted. Iconic ๐Ÿ’€
  • zap-up-to-char โ€” like zap-to-char but it doesn't delete the target character. So the char you aimed at survives the culling ๐ŸŒธ

๐Ÿ—‚๏ธ MG DIRED KEY BINDINGS

Dired mode has its own whole set of specific key bindings, and honestly the way it just has them all mapped out? Obsessed.

  • DEL โ€” dired-unmark-backward
  • RET, e, f and C-m โ€” dired-find-file
  • SPC, n โ€” dired-next-line
  • ! โ€” dired-shell-command
  • + โ€” dired-create-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

And here's the full list of commands that are specific to dired mode, one by one, no skips no capes ๐Ÿ’–

  • dired-create-directory โ€” creates a directory. New folder, new era ๐ŸŽ€
  • dired-do-copy โ€” copies the file listed on the current line of the dired buffer.
  • dired-do-flagged-delete โ€” deletes all the files that have been flagged for deletion. This is the moment where the flags actually mean something ๐Ÿ”ฅ
  • dired-do-rename โ€” renames the file listed on the current line of the dired buffer.
  • dired-find-alternate-file โ€” swaps the current dired buffer out for an alternate one as specified by the position of the cursor in the dired buffer. Glow-up via relocation โœจ
  • dired-find-file โ€” opens the file on the current line of the dired buffer. And if the cursor is on a directory? It gets opened in dired mode. Directory-ception, we love it ๐Ÿฆ‹
  • dired-flag-file-deletion โ€” flags the file listed on the current line for deletion. You'll see it in the buffer as a D dropped at the left margin. But here's the thing bestie โ€” no files are actually deleted until the function dired-do-flagged-delete is executed. Safety first, slay later ๐Ÿ’…
  • dired-find-file-other-window โ€” opens the file on the current line of the dired buffer, but in a different window. Main character, two stages ๐ŸŽญ
  • dired-goto-file โ€” moves the cursor to a file name in the dired buffer.
  • dired-next-line โ€” moves the cursor to the next line.
  • dired-other-window โ€” works just like dired, except that it puts the dired buffer in another window.
  • dired-previous-line โ€” moves the cursor to the previous line.
  • dired-revert โ€” refreshes the dired buffer while retaining any flags. Note: keeps your flags. Respects your choices ๐Ÿซถ
  • dired-scroll-down โ€” scrolls down the dired buffer.
  • dired-scroll-up โ€” scrolls up the dired buffer.
  • dired-shell-command โ€” pipes the file under the current cursor position through a shell command. Your file, her pipeline ๐Ÿ”ฅ
  • dired-unmark โ€” removes the deletion flag for the file on the current line. Change of heart, valid ๐Ÿ’–
  • dired-unmark-backward โ€” removes the deletion flag from the file listed on the previous line of the dired buffer, then moves up to that line.
  • quit-window โ€” closes the current dired buffer. Bye bestie ๐Ÿ‘‹

๐ŸŽ€ CONFIGURATION FILES

Okay so there are exactly two configuration files: .mg and .mg-$TERM. Here, $TERM represents the name of the terminal type โ€” like, if the terminal type is set to โ€œvt100โ€, mg will use .mg-vt100 as a startup file. And the terminal type startup file is used first โญ

The startup file format is literally just a list of commands, one per line, same ones you'd use for interactive evaluation. And any strings that you'd normally type in at those later prompts? You can just put them right after the command name. Obsessed with the efficiency ๐Ÿ’… 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

Wanna leave notes for your future self (or your mutuals)? You can add comments to the startup files by placing โ€˜;โ€™ or โ€˜#โ€™ as the first character of a line. Little love notes to your config ๐Ÿฅบ


๐Ÿ“ 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


โš ๏ธ CAVEATS

Real talk time, bestie, because these matter:

  • Since mg is written completely in C, there is currently no language in which extensions can be written. No plugin era yet ๐Ÿ˜ญ However โ€” keys can be rebound, and certain parameters can be changed in startup files. So you're not totally powerless ๐Ÿ’ช
  • In order to use 8-bit characters (such as German umlauts), you need to disable the Meta key via the meta-key-mode command. Not optional, fr fr.
  • Multi-byte character sets, such as UTF-8, are not supported. Like, at all. Read that again. ๐Ÿซ 
๐Ÿ’€ Genuinely: if your whole workflow is multilingual emoji-laden text, this is your vibe check and the vibe is no. Plan accordingly.

And that's the whole page, bestie โ€” you made it to the end, I'm so proud ๐Ÿฅน๐ŸŽ€ This one's a Debian build, dated Aug 9, 2023, and it's MG(1) โ€” go forth and edit iconically ๐Ÿ‘‘โœจ

๐Ÿ“ฆ where this page comes from