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.+-1will be the last line of the file,+-2will be second last, and so on. counting backwards is lowkey a flex โจ-b fileโ turn on batch mode and execute themgcommands 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-commandC-a,Homeโbeginning-of-lineC-b,Leftโbackward-charC-c s cโcscope-find-functions-calling-this-functionC-c s dโcscope-find-global-definitionC-c s eโcscope-find-egrep-patternC-c s fโcscope-find-this-fileC-c s iโcscope-find-files-including-fileC-c s nโcscope-next-symbolC-c s pโcscope-prev-symbolC-c s sโcscope-find-this-symbolC-c s tโcscope-find-this-text-stringC-d,Deleteโdelete-charC-e,Endโend-of-lineC-f,Rightโforward-charC-gโkeyboard-quitC-h C-hโhelp-helpC-h aโaproposC-h bโdescribe-bindingsC-h cโdescribe-key-brieflyC-h tโtutorialC-h qโquick-helpC-jโnewline-and-indentC-kโkill-lineC-lโrecenterRETโnewlineC-n,Downโnext-lineC-oโopen-lineC-p,Upโprevious-lineC-qโquoted-insertC-rโisearch-backwardC-sโisearch-forwardC-tโtranspose-charsC-uโuniversal-argumentC-vโscroll-upC-wโkill-regionC-x C-bโlist-buffersC-x C-cโsave-buffers-kill-emacsC-x C-fโfind-fileC-x C-jโdired-jumpC-x C-gโkeyboard-quitC-x C-lโdowncase-regionC-x C-oโdelete-blank-linesC-x C-qโtoggle-read-onlyC-x C-rโfind-file-read-onlyC-x C-sโsave-bufferC-x C-uโupcase-regionC-x C-vโfind-alternate-fileC-x C-wโwrite-fileC-x C-xโexchange-point-and-markC-x (โstart-kbd-macroC-x )โend-kbd-macroC-x 0โdelete-windowC-x 1โdelete-other-windowsC-x 2โsplit-window-verticallyC-x 4 C-fโfind-file-other-windowC-x 4 C-gโkeyboard-quitC-x 4 bโswitch-to-buffer-other-windowC-x 4 fโfind-file-other-windowC-x =โwhat-cursor-positionC-x ^โenlarge-windowC-x ```` โnext-errorC-x bโswitch-to-bufferC-x dโdiredC-x eโcall-last-kbd-macroC-x fโset-fill-columnC-x gโgoto-lineC-x hโmark-whole-bufferC-x iโinsert-fileC-x kโkill-bufferC-x nโother-windowC-x oโother-windowC-x pโprevious-windowC-x sโsave-some-buffersC-x uโundoC-yโyankC-zโsuspend-emacsM-C-vโscroll-other-windowM-SPCโjust-one-spaceM-!โshell-commandM-.โfind-tagM-*,M-,โpop-tag-markM-%โquery-replaceM-<,C-PgUpโbeginning-of-bufferM->,C-PgDnโend-of-bufferM-\โdelete-horizontal-spaceM-^โjoin-lineM-b,C-left,M-leftโbackward-wordM-cโcapitalize-wordM-dโkill-wordM-f,C-right,M-rightโforward-wordM-hโmark-paragraphM-lโdowncase-wordM-mโback-to-indentationM-qโfill-paragraphM-rโsearch-backwardM-sโsearch-forwardM-tโtranspose-wordsM-uโupcase-wordM-vโscroll-downM-wโcopy-region-as-killM-xโexecute-extended-commandM-zโzap-to-charM-{,C-downโbackward-paragraphM-|โshell-command-on-regionM-},C-upโforward-paragraphM-~โnot-modifiedM-DELโbackward-kill-wordC-_โundo)โblink-and-insertDELโ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 allmgcommands 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 withset-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 withset-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.ddirectory instead of working directory. requiresmake-backup-filesto 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 theglobal-set-keycommand. ๐ฆbsmap-modeโ Toggles bsmap mode, whereDELandC-hare 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 alsoglobal-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 akill-regionfollowed by ayank. ๐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#includethe 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. Likedelete-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 asfind-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 asfind-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-incrementalsearch-backwardis 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-incrementalsearch-forwardis 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 of0, 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 backabs(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 howbackup-to-home-directorybehaves ๐ Backup files that would normally live in/tmpget left right there and are not moved into the~/.mg.ddirectory. 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, respectingno-tab-modeand 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 withset-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 withset-default-mode.prefix-regionโ inserts a prefix string before each line of a region ๐ธ The prefix string is settable by usingset-prefix-stringor 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 wherefind-tagwas previously invoked ๐push-shellโ suspendsmgand 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.displaydoes 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 quitmg๐ญ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 affectsfill-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, andoverwrite.set-fill-columnโ prompts the user for a fill column ๐ Used byauto-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 theprefix-regioncommand โญ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 invokingend-kbd-macro.suspend-emacsโ suspendsmgand 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 themgtutorial, 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 toC-u. This command may be stacked; e.g.C-u C-u C-fmoves 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 subsequentfind-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 thekill-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โ likezap-to-charbut 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-backwardRET,e,fandC-mโdired-find-fileSPC,nโdired-next-line!โdired-shell-command+โdired-create-directoryaโdired-find-alternate-filecโdired-do-copydandC-dโdired-flag-file-deletiongโdired-revertjโdired-goto-fileoโdired-find-file-other-windowpโdired-previous-lineqโquit-windowrโdired-do-renameuโdired-unmarkxโdired-do-flagged-deleteC-vโdired-scroll-downM-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 aDdropped at the left margin. But here's the thing bestie โ no files are actually deleted until the functiondired-do-flagged-deleteis 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 likedired, 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-modecommand. 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
- opensuse-leap 16.0: mg 3.7-bp160.1.13 ยท Unlicense
- opensuse-leap 16.0: mg 3.7-bp160.1.13 ยท Unlicense
- opensuse-leap 16.0: mg 3.7-bp160.1.13 ยท Unlicense
- opensuse-leap 16.0: mg 3.7-bp160.1.13 ยท Unlicense
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms