MCEDIT(1)
π MCEDIT(1) β the GNU Midnight Commander girlies' manual π
okay so bestie, welcome to mcedit(1), aka the internal file editor of GNU Midnight Commander β¨ (yes the manual page header says MCEDIT(1) and the manual name is GNU Midnight Commander, we're just folding that in up top so it looks cute π)
πΈ NAME πΈ
mcedit β the internal file editor of GNU Midnight Commander. that's it. that's the name. π
β¨ SYNOPSIS β¨
mcedit [-bcCdfhstVx?] [+lineno] [file1] [file2] ...
mcedit [-bcCdfhstVx?] file1:lineno[:] file2:lineno[:] ...
look at her go π¦ two whole invocation shapes, both iconic.
π DESCRIPTION π
So mcedit is literally a link to mc, the main GNU Midnight Commander executable. not me being a whole separate binary, I'm a symlink bestie π. When you execute GNU Midnight Commander under this name, it runs the internal editor and opens the files you specified on the command line. The editor is based on the terminal version of cooledit β the standalone editor for the X Window System. heritage. legacy. we love an origin story. π
π OPTIONS π
+linenoβ go straight to the line specified by number. β οΈ do not put a space between the+sign and the number, ok? Several line numbers are allowed but only the last one will be used, and it will be applied to the first file only. so pick a favourite, she's monogamous. π-bβ force black and white display. monochrome moment π€π€-cβ force ANSI color mode on terminals that don't seem to have color support. gaslighting your terminal into being colorful, slay π-C <keyword>=<fgcolor>,<bgcolor>,<attributes>:<keyword>= ...β specify a different color set. See the Colors section inmc(1)for more information. yes bestie, go readmc(1), she has the tea β-dβ disable mouse support. no mouse for you π-fβ display the compiled-in search path for GNU Midnight Commander data files. she's showing you where she keeps her stuff π«Ά-tβ force using thetermcapdatabase instead ofterminfo. This option is only applicable if GNU Midnight Commander was compiled with the S-Lang library with terminfo support. conditional queen, only applies sometimes π-Vβ display the version of the program. identity reveal β¨-xβ force xterm mode. Used when running on xterm-capable terminals (two screen modes, and able to send mouse escape sequences). escape sequences?? she's dramatic and I respect it π¦
π₯ FEATURES π₯
The internal file editor is a full-featured windowed editor. full-featured. windowed. main character energy. π She can edit several files at the same time. Maximum size of each file is 64 megabytes. It is possible to edit binary files. binary!! she's not scared of anything π€
The features she presently supports are:
- block copy, move, delete, cut, paste
- key for key undo
- pull-down menus
- file insertion
- macro commands
- regular expression search and replace
- shift-arrow text highlighting (if supported by the terminal)
- insert-overwrite toggle
- autoindent
- tunable tab size
- syntax highlighting for various file types
- and an option to pipe text blocks through shell commands like
indentandispell
the way that she does ALL of thisβ¦ obsessed fr fr π
Each file is opened in its own window in full-screen mode. Window control in mcedit is similar to the window control in other multi-window programs:
- double click on window title maximizes the window to full-screen, or restores window size and position πͺ
- left-click on window title and mouse drag moves the window in the editor area π±οΈ
- left-click on low-right frame corner and mouse drag resizes the window π
These actions can be made using the "Window" menu too. menu girlies rise up β¨
π¦ KEYS π¦
The editor is easy to use and can be used without learning. lowkey the nicest thing anyone's ever said about a text editor π₯Ή The pull-down menu is invoked by pressing F9. You can learn other keys from the menu and from the button bar labels. she literally teaches you herself, self-sufficient icon π
In addition to that, Shift combined with arrows does text highlighting (if supported by the terminal):
- Ctrl-Ins copies to the file
~/.cache/mc/mcedit/mcedit.clipπ - Shift-Ins pastes from
~/.cache/mc/mcedit/mcedit.clipπ«Ά - Shift-Del cuts to
~/.cache/mc/mcedit/mcedit.clipβοΈ - Ctrl-Del deletes highlighted text π
Mouse highlighting also works on some terminals. To use the standard mouse support provided by your terminal, hold the Shift key.
β οΈ please note that the mouse support in the terminal doesn't share the clipboard with mcedit. two different clipboards, two different worlds, no crossover bestie π
The completion key (usually Meta-Tab or Escape Tab) completes the word under the cursor using the words used in the file. autocomplete but make it homemade β¨
π MACRO π
To define a macro, press Ctrl-R and then type out the keys you want to be executed. Press Ctrl-R again when finished. The macro can be assigned to any key by pressing that key. The macro is executed when you press the assigned key. you're literally programming her with your vibes, iconic π
The macro commands are stored in section [editor] in the file ~/.local/share/mc/mc.macros.
External scripts (filters) can be assigned into any hotkey by editing mc.macros like following:
[editor]
ctrl-W=ExecuteScript:25;
This means that ctrl-W hotkey initiates the ExecuteScript(25) action, then the editor handler translates this into execution of ~/.local/share/mc/mcedit/macros.d/macro.25.sh shell script. a whole pipeline just to run your lil script, she's extra and I love her π
External scripts are stored in ~/.local/share/mc/mcedit/macros.d/ directory and must be named as macro.XXXX.sh where XXXX is the number from 0 to 9999. See Edit Menu File for more detail about format of the script. naming convention queen, no cap π
Following macro definition and directives can be used:
#silentβ if this directive is set, then the script starts without interactive subshell. quiet mode activated π€«%cβ the cursor column position number.%iβ the indent of blank space, equal the cursor column.%yβ the syntax type of current file.%bβ the block file name.%fβ the current file name.%nβ only the current file name without extension.%xβ the extension of current file name.%dβ the current directory name.%Fβ the current file in the unselected panel.%Dβ the directory name of the unselected panel.%tβ the currently tagged files.%Tβ the tagged files in the unselected panel.%uand%Uβ similar to the%tand%Tmacros, but in addition the files are untagged. You can use this macro only once per menu file entry or extension file entry, because next time there will be no tagged files. one-time use bestie, she doesn't do encores π%sand%Sβ the selected files: the tagged files if there are any. Otherwise the current file. fallback behaviour, we stan a flexible girl π
Feel free to edit this files, if you need. Here is a sample external script:
l comment selection
TMPFILE=`mktemp ${MC_TMPDIR:-/tmp}/up.XXXXXX` || exit 1
echo #if 0 > $TMPFILE
cat %b >> $TMPFILE
echo #endif >> $TMPFILE
cat $TMPFILE > %b
rm -f $TMPFILE
If some keys don't work, you can use Learn Keys in the Options menu. she's got a whole lesson plan for your keyboard π«Ά
π CODE NAVIGATION π
mcedit can be used for navigation through code with tags files created by etags or ctags commands. code navigation era!! If there is no TAGS file, code navigation will not work. no TAGS file = no navigation, periodt. π
For example, in case of exuberant-ctags for C language the command will be:
ctags -e --language-force=C -R ./
- Meta-Enter β shows list box to select item under cursor (cursor should stand at the end of the word). end of the word bestie, don't embarrass yourself π
- Meta-Minus β where minus is symbol
"-", goes to previous function in navigation list (like browser's Back button). β¬ οΈ - Meta-Equal β where equal is symbol
"=", goes to next function in navigation list (like browser's Forward button). β‘οΈ
back and forward buttons but make it code, she's a whole browser now, obsessed β¨
bestie this is only <b>part 1</b> of 3, there's more coming, don't go anywhere π
β¨ SYNTAX HIGHLIGHTING β¨
okay bestie, let's talk about making your code look like a whole vibe. mcedit supports syntax highlighting π
. That means keywords and contexts (like C comments, string constants, etc) get highlighted in different colors. The way it works is explained in the file ~/.local/share/mc/syntax/Syntax. If that file is missing, the system-wide /usr/share/mc/syntax/Syntax is used. And listen: ~/.local/share/mc/syntax/Syntax gets rescanned every time you open a new editor file. The file contains rules for highlighting, each on a separate line, and they define which keywords get what color.
The file is divided into sections, each starting with a line that has the file command. Normally you'd put sections in separate files using the include command.
The file command takes three arguments. First argument is a regular expression applied to the file name to see if the following section applies. Second argument is the description of the file type. It's used in cooledit; future versions of mcedit may use it too. Third optional argument is a regular expression to match the first line of text of the file. The rules in the following section apply if either the file name or the first line of text matches.
A section ends when another section starts. Each section is divided into contexts, and each context contains rules. A context is like a scope within the text that a particular set of rules belongs to. For instance, the text inside a C style comment (i.e. between /* and */) has its own color. That's a context, even though it has no further rules inside it because there's probably nothing we want highlighted inside a C comment.
A trivial C programming section might look like this:
file .\*\\.c C\sProgram\sFile (#include|/\\\*)
wholechars abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_
# default colors
define comment brown
context default
keyword whole if yellow
keyword whole else yellow
keyword whole for yellow
keyword whole while yellow
keyword whole do yellow
keyword whole switch yellow
keyword whole case yellow
keyword whole static yellow
keyword whole extern yellow
keyword { brightcyan
keyword } brightcyan
keyword '*' green
# C comments
context /\* \*/ comment
# C preprocessor directives
context linestart # \n red
keyword \\\n brightred
# C string constants
context " " green
keyword %d brightgreen
keyword %s brightgreen
keyword %c brightgreen
keyword \\" brightgreen
Each context starts with a line of the form:
context [exclusive] [whole|wholeright|wholeleft] [linestart] delim [linestart] delim [foreground] [background] [attributes]
But the first context is special. It must start with the command:
context default [foreground] [background] [attributes]
otherwise mcedit will report an error π¨. The linestart option says that delim must start at the beginning of a line. The whole option says delim must be a whole word. If you want a word that must begin on the word boundary only on the left side, use wholeleft, and similarly a word that must end on the word boundary is wholeright.
The set of characters that make up a whole word can be changed anytime with the wholechars command. You can set left and right sets separately with:
wholechars [left|right] characters
The exclusive option makes it so the text between the delimiters is highlighted, but not the delimiters themselves.
Each rule is a line of the form:
keyword [whole|wholeright|wholeleft] [linestart] string foreground [background] [attributes]
Context or keyword strings are interpreted, so you can include tabs and spaces with \t and \s. Newlines and backslashes are \n and \\ respectively. Since whitespace is a separator, you can't use it as is. Also, \* must be used for an asterisk. The * itself is a wildcard that matches any length of characters. For example,
keyword '*' green
colors all C single character constants green. You could also use
keyword "*" green
to color string constants, but then the matched string can't span multiple newlines. The wildcard can be used within context delimiters too, but you can't have a wildcard as the last or first character.
Important to note is the line
keyword \\\n brightgreen
This line defines a keyword containing the backslash and newline characters. Since keywords are matched before context delimiters, this keyword stops the context from ending at the end of lines that end in a backslash, which lets C preprocessor directives continue across multiple lines.
The possible colors are: black, gray, red, brightred, green, brightgreen, brown, yellow, blue, brightblue, magenta, brightmagenta, cyan, brightcyan, lightgray and white. The special keyword "default" means the terminal's default. Another special keyword "base" means mc's main colors, useful as a placeholder if you want to specify attributes without modifying the background color. When 256 colors are available, they can be specified either as color16 to color255, or as rgb000 to rgb555 and gray0 to gray23.
If the syntax file is shared with cooledit, you can specify different colors for mcedit and cooledit by separating them with a slash, e.g.
keyword #include red/Orange
mcedit uses the color before the slash. See cooledit(1) for supported cooledit colors.
Attributes can be any of bold, italic, underline, reverse and blink, appended by a plus sign if you want more than one.
Comments can be put on a separate line starting with the hash sign (#).
If you're describing a case insensitive language you need to use the caseinsensitive directive. It should be specified at the beginning of the syntax file.
Because of the simplicity of the implementation, there are a few intricacies that won't be dealt with correctly, but these are a minor irritation π. On the whole, a broad spectrum of quite complicated situations are handled with these simple rules. It's a good idea to take a look at the syntax file to see some of the nifty tricks you can do with a little imagination. If you can't get by with the rules I've coded, and you think you have a rule that would be useful, please email me with your request.
However, do not ask for regular expression support, because this is flatly impossible. periodt. π
A useful hint is to work with as much as possible with the things you can do rather than try to do things that this implementation can't deal with. Also remember that the aim of syntax highlighting is to make programming less prone to error, not to make code look pretty.
The syntax highlighting can be toggled using Ctrl-s shortcut. β¨
π¨ COLORS π¨
The default colors can be changed by appending to the MC_COLOR_TABLE environment variable. Foreground and background color pairs can be specified for example with:
MC_COLOR_TABLE="$MC_COLOR_TABLE:\
editnormal=lightgray,black:\
editbold=yellow,black:\
editmarked=black,cyan"
Okay so before we get into the lineup β most of these? You can just flip them from the Options dialog box. Go peep the Options menu. π The options below are defined in ~/.config/mc/ini and they all have obvious counterparts in that dialog box. You can change your editor's whole behavior just by editing that file. And unless it says otherwise: a 1 = on, a 0 = off, as usual. periodt. π
use_internal_editβ this one is literally ignored when you invokemcedit. like, it doesn't care. πeditor_tab_spacingβ treat the tab character as being this long. Default is8. And bestie, please avoid anything other than8, because most other editors and text viewers just assume a tab spacing of8. Wanna fake a smaller tab spacing? Useeditor_fake_half_tabsinstead. πeditor_fill_tabs_with_spacesβ never insert a tab character, ever. Instead insert spaces (ascii32) to fill to the desired tab size. so clean, so safe. β¨editor_return_does_auto_indentβ hitting return will tab across to match the indentation of the first line above that has text on it. auto-aligned, no thoughts, iconic. πeditor_backspace_through_tabsβ one single backspace deletes all the space to the left margin, if there's no text between the cursor and the left margin. bye bye whitespace. πeditor_fake_half_tabsβ this emulates a half tab for the girlies who wanna program with a tab spacing of4but do not want the tab size changed from8(so their code still formats the same when other programs display it). When you're editing between text and the left margin, moving and tabbing will act as though a tab space were4, while actually using spaces and normal tabs for an optimal fill. When you're editing anywhere else, a normal tab gets inserted. it's giving best of both worlds fr fr. π¦editor_option_save_modeβ possible values0,1and2. The save mode (also in the options menu) lets you change the method of saving a file.- Quick save (
0) β saves the file immediately, truncating the disk file to zero length (i.e. erasing it) and then writing the editor contents to the file. This method is fast, but dangerous, since a system error during a file save will leave the file only partially written, possibly rendering the data irretrievable. π - Safe save (
1) β when saving, this option enables creation of a temporary file into which the file contents are first written. In the event of a problem, the original file is untouched. When the temporary file is successfully written, it is renamed to the name of the original file, thus replacing it. π«Ά - Create backups (
2) β the safest method: a backup file is created before any changes are made. You can specify your own backup file extension in the dialog. > Heads up though: saving twice will replace your backup as well as your original file. so watch out. πΈ
- Quick save (
editor_word_wrap_line_lengthβ the line length to wrap at. Default is72.editor_backup_extensionβ the symbol to add to the name of backup files. Default is"~".editor_line_stateβ show the state line of the editor. Currently it shows the current line number (in the future it might show things like folding, breakpoints, etc.).M-ntoggles this option. βeditor_visible_spacesβ toggle "show visible trailing spaces". Ifeditor_visible_spaces=1, they are shown as'.'editor_visible_tabsβ toggle "show visible tabs". Ifeditor_visible_tabs=1, tabs are shown as'<---->'editor_persistent_selectionsβ do not remove the block selection after cursor movement. the selection stays. slay. πeditor_drop_selection_on_copyβ reset the selection after copy to clipboard.editor_cursor_beyond_eolβ allow moving the cursor beyond the end of line.editor_cursor_after_inserted_blockβ allow moving the cursor after the inserted block.editor_syntax_highlightingβ enable syntax highlighting. πeditor_edit_confirm_saveβ show a confirmation dialog on save. (asking permission first, as she should. π)editor_option_typewriter_wrapβ to be described.editor_option_auto_para_formattingβ to be described.editor_option_save_positionβ save the file position on exit.source_codepageβ symbol representation of codepage name for the file (i.e.CP1251,~- default).editor_group_undoβ combine UNDO actions for several of the same type of action (inserting/overwriting, deleting, navigating, typing). fewer undos, less chaos. β¨editor_wordcompletion_collect_entire_fileβ search autocomplete candidates in the entire file (1) or just from the beginning of the file to the cursor position (0).editor_wordcompletion_collect_all_filesβ search autocomplete candidates from all loaded files (1, default), not only from the currently edited one (0).spell_languageβ spelling language (en,en-variant_0,ru, etc) installed with the aspell package (a full list can be obtained using the'aspell'utility). Usespell_language = NONEto disable aspell support. Default value is'en'. > This option must be located in the[Misc]section. don't put it anywhere else bestie. πeditor_stop_format_charsβ set of characters to stop paragraph formatting. If one of those characters is found at the beginning of a line, that line and all following lines of the paragraph will be untouched. Default value is"-+*\,.;:&>".editor_state_full_filenameβ show the full path name in the status line. If disabled (default), only the base name of the file is shown.
πΈ MISCELLANEOUS πΈ
The editor also displays non-us characters (160+). And when you're editing binary files, you should set display bits to 7 bits in Midnight Commander's options menu to keep the spacing clean. π§
π FILES π
/usr/share/mc/help/mc.hlpβ the help file for the program./usr/share/mc/mc.iniβ the default system-wide setup for GNU Midnight Commander, used only if the user's own~/.config/mc/inifile is missing./usr/share/mc/mc.libβ global settings for Midnight Commander. Settings in this file affect all users, whether they have~/.config/mc/inior not./usr/share/mc/syntax/*β the default system-wide syntax files formcedit, used only if the corresponding user's own file in~/.local/share/mc/syntax/is missing.~/.config/mc/iniβ user's own setup. If this file is present then the setup is loaded from here instead of the system-wide setup file.~/.local/share/mc/mcedit/β user's own directory where block commands are processed and saved and user's own syntax files are located.
π LICENSE π
This program is distributed under the terms of the GNU General Public License as published by the Free Software Foundation. See the built-in help of Midnight Commander for details on the License and the lack of warranty. (yeah, no warranty, we said what we said. π)
β AVAILABILITY β
The latest version of this program can be found at http://ftp.midnight-commander.org/.
π¦ SEE ALSO π¦
cooledit(1), mc(1), gpm(1), terminfo(1), scanf(3).
π«Ά AUTHORS π«Ά
Paul Sheer (psheer@obsidian.co.za) is the original author of Midnight Commander's internal editor. absolute legend, we stan. π
π₯ BUGS π₯
Bugs should be reported to https://www.midnight-commander.org/.
okay that's the whole page bestie!! this one's MC Version 4.8.33, dated January 2025, and it's the MCEDIT(1) page. go forth and edit your little heart out, you're gonna eat. π
β¨π
π¦ where this page comes from
- alpine 3.22: mc-doc 4.8.33-r2 Β· GPL-3.0-or-later
- alpine 3.23: mc-doc 4.8.33-r2 Β· GPL-3.0-or-later
- alpine 3.24: mc-doc 4.8.33-r3 Β· GPL-3.0-or-later
- arch rolling: mc 4.8.33-1 Β· GPL-3.0-or-later
- fedora 43: mc 1:4.8.33-2.fc43 Β· GPL-3.0-or-later
- fedora 44: mc 1:4.8.33-3.fc44 Β· GPL-3.0-or-later
- opensuse-leap 16.0: mc 4.8.33-bp160.1.1 Β· GPL-3.0-or-later
- opensuse-leap 16.0: mc 4.8.33-bp160.1.1 Β· GPL-3.0-or-later
- opensuse-leap 16.0: mc 4.8.33-bp160.1.1 Β· GPL-3.0-or-later
- opensuse-leap 16.0: mc 4.8.33-bp160.1.1 Β· GPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms