# MCEDIT - Internal file editor of GNU Midnight Commander. - man(1) - [phpMan]

[_MCEDIT_(1)](https://www.chedong.com/phpMan.php/man/MCEDIT/1/markdown)                              GNU Midnight Commander                              [_MCEDIT_(1)](https://www.chedong.com/phpMan.php/man/MCEDIT/1/markdown)

## NAME
       mcedit - Internal file editor of GNU Midnight Commander.

## SYNOPSIS
       **mcedit **[-bcCdfhstVx?] [+lineno] [file1] [file2] ...

       **mcedit **[-bcCdfhstVx?] file1:lineno[:] file2:lineno[:] ...

## DESCRIPTION
       mcedit  is  a  link to **mc**, the main GNU Midnight Commander executable. Executing GNU Midnight
       Commander under this name runs the internal editor and opens files specified on  the  command
       line.  The editor is based on the terminal version of **cooledit **- standalone editor for X Win‐
       dow System.

## OPTIONS
       _+lineno_
              Go to the line specified by number (do not put a space between the _+_ sign and the num‐
              ber). Several line numbers are allowed but only the last one will be used, and it will
              be applied to the first file only.

       _-b_     Force black and white display.

       _-c_     Force ANSI color mode on terminals that don't seem to have color support.

       _-C_ _<keyword>=<fgcolor>,<bgcolor>,<attributes>:<keyword>=_ _..._
              Specify a different color set.  See the **Colors **section in [mc(1)](https://www.chedong.com/phpMan.php/man/mc/1/markdown) for more information.

       _-d_     Disable mouse support.

       _-f_     Display the compiled-in search path for GNU Midnight Commander data files.

       _-t_     Force using termcap database instead of terminfo.  This option is only  applicable  if
              GNU Midnight Commander was compiled with S-Lang library with terminfo support.

       _-V_     Display the version of the program.

       _-x_     Force xterm mode.  Used when running on xterm-capable terminals (two screen modes, and
              able to send mouse escape sequences).

## FEATURES
       The  internal  file  editor is a full-featured windowed editor.  It can edit several files at
       the same time. Maximum size of each file is 64 megabytes.  It  is  possible  to  edit  binary
       files.  The features it presently supports are: block copy, move, delete, cut, paste; key for
       key undo; pull-down menus; file insertion; macro commands; regular expression search and  re‐
       place; 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 indent and ispell.

       Each file is opened in its own window in full-screen mode. Window control in mcedit is  simi‐
       lar  to  the window control in other multi-window program: double click on window title maxi‐
       mizes the window to full-screen or restores window size and position;  left-click  on  window
       title  and  mouse  drag moves the window in editor area; left-click on low-right frame corner
       and mouse drag resizes the window. These actions can be made using "Window" menu.

## KEYS
       The editor is easy to use and can be used without learning.  The pull-down menu is invoked by
       pressing F9.  You can learn other keys from the menu and from the button bar labels.

       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**,   and
       **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**.

       The completion key (usually **Meta-Tab **or **Escape Tab**) completes the word under the cursor using
       the words used in the file.

## 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.

       The macro commands are stored in section **[editor] **it the file **~/.local/share/mc/mc.macros**.

       External scripts (filters) can be assigned into the any hotkey by edit **mc.macros **like follow‐
       ing:

       [editor]
       ctrl-W=ExecuteScript:25;

       This  means  that  ctrl-W  hotkey initiates the [_ExecuteScript(25)](https://www.chedong.com/phpMan.php/man/ExecuteScript/25/markdown)_ action, then editor handler
       translates this into execution of **~/.local/share/mc/mcedit/macros.d/macro.25.sh **shell script.

       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.

       Following macro definition and directives can be used:

       _#silent_
              If this directive is set, then script starts without interactive subshell.

       _%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.

       _%u_ and _%U_
              Similar to the _%t_ and _%T_ macros, 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.

       _%s_ and _%S_
              The selected files: The tagged files if there are any. Otherwise the current file.

       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.

## CODE NAVIGATION
       **mcedit **can be used for navigation through code with tags files created by etags or ctags com‐
       mands. If there is no TAGS file code navigation will not work.  For example, in case of  exu‐
       berant-ctags for C language 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).

       **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).

## SYNTAX HIGHLIGHTING
       **mcedit **supports syntax highlighting.  This means that keywords and contexts (like C comments,
       string  constants,  etc) are highlighted in different colors.  The following section explains
       the format of the file **~/.local/share/mc/syntax/Syntax**.  If this file is missing, system-wide
       **/usr/share/mc/syntax/Syntax **is used.  The file **~/.local/share/mc/syntax/Syntax  **is  rescanned
       on opening of every new editor file.  The file contains rules for highlighting, each of which
       is given on a separate line, and define which keywords will be highlighted with what color.

       The  file  is  divided  into sections, each beginning with a line with the **file **command.  The
       sections are normally put into separate files using the **include **command.

       The **file **command has three arguments.  The first argument is a regular expression that is ap‐
       plied to the file name to determine if the following section applies to the file.  The second
       argument is the description of the file type.  It is used in  **cooledit**;  future  versions  of
       **mcedit  **may use it as well.  The 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 with the start of another section.  Each section is divided into contexts, and
       each  context  contains rules.  A context is a scope within the text that a particular set of
       rules belongs to.  For instance, the text within a C style comment (i.e. between **/*  **and  ***/**)
       has  its  own  color.   This is a context, although it has no further rules inside it because
       there is probably nothing that we want highlighted within 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_  [_fore‐_
       _ground_] [_background_] [_attributes_]

       The first context is an exception.  It must start with the command

       **context default **[_foreground_] [_background_] [_attributes_]

       otherwise  **mcedit **will report an error.  The **linestart **option specifies that _delim_ must start
       at the beginning of a line.  The **whole **option tells that _delim_ must  be  a  whole  word.   To
       specify  that  a  word must begin on the word boundary only on the left side, you can use the
       **wholeleft **option, and similarly a word that must end on the word  boundary  is  specified  by
       **wholeright**.

       The  set  of  characters that constitute a whole word can be changed at any point in the file
       with the **wholechars **command.  The left and right set of characters can be set separately with

       **wholechars **[**left**|**right**] _characters_

       The **exclusive **option causes the text between the delimiters to be 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 that you can include tabs and spaces with the
       sequences \t and \s.  Newlines and backslashes are specified with  \n  and  \\  respectively.
       Since  whitespace is used as a separator, it may not be used as is.  Also, \* must be used to
       specify 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 also could use

         keyword         "*"      green

       to  color string constants, but the matched string would not be allowed to span across multi‐
       ple newlines.  The wildcard may be used within context delimiters as  well,  but  you  cannot
       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 the key‐
       words are matched before the context delimiters, this keyword prevents the context from  end‐
       ing  at  the end of the lines that end in a backslash, thus allowing C preprocessor directive
       to 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, it is useful as a placeholder if you want to specify attributes without modify‐
       ing 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**, it is possible to 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)](https://www.chedong.com/phpMan.php/man/cooledit/1/markdown) for supported **cooledit **colors.

       Attributes can be any of bold, italic, underline, reverse and blink, appended by a plus  sign
       if more than one are desired.

       Comments may be put on a separate line starting with the hash sign (#).

       If you are describing case insensitive language you need to use **caseinsensitive **directive. It
       should be specified at the beginning of syntax file.

       Because of the simplicity of the implementation, there are a few intricacies that will not 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 is a good idea to  take
       a  look  at the syntax file to see some of the nifty tricks you can do with a little imagina‐
       tion.  If you cannot get by with the rules I have coded, and you think you have a  rule  that
       would  be useful, please email me with your request.  However, do not ask for regular expres‐
       sion support, because this is flatly impossible.

       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 cannot 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  may be changed by appending to the **MC_COLOR_TABLE **environment variable.
       Foreground and background colors pairs may be specified for example with:

       MC_COLOR_TABLE="$MC_COLOR_TABLE:\
       editnormal=lightgray,black:\
       editbold=yellow,black:\
       editmarked=black,cyan"

## OPTIONS
       Most options can be set from Options dialog box.  See the **Options **menu.   The  following  op‐
       tions  are  defined in **~/.config/mc/ini **and have obvious counterparts in the dialog box.  You
       can modify them to change the editor behavior, by editing the file.  Unless  specified,  a  1
       sets the option to on, and a 0 sets it to off, as usual.

       _use_internal_edit_
              This option is ignored when invoking **mcedit**.

       _editor_tab_spacing_
              Interpret  the  tab character as being of this length.  Default is 8. You should avoid
              using other than 8 since most other editors and text viewers assume a tab  spacing  of
              8. Use **editor_fake_half_tabs **to simulate a smaller tab spacing.

       _editor_fill_tabs_with_spaces_
              Never  insert  a tab character. Rather insert spaces (ascii 32) to fill to the desired
              tab size.

       _editor_return_does_auto_indent_
              Pressing return will tab across to match the indentation of the first line above  that
              has text on it.

       _editor_backspace_through_tabs_
              Make  a  single  backspace delete all the space to the left margin if there is no text
              between the cursor and the left margin.

       _editor_fake_half_tabs_
              This will emulate a half tab for those who want to program with a tab  spacing  of  4,
              but  do  not  want the tab size changed from 8 (so that the code will be formatted the
              same when displayed by other programs). When editing between text and the left margin,
              moving and tabbing will be as though a tab space were 4, while actually  using  spaces
              and  normal tabs for an optimal fill.  When editing anywhere else, a normal tab is in‐
              serted.

       _editor_option_save_mode_
              Possible values 0, 1 and 2.  The save mode (see the options menu also) allows  you  to
              change  the method of saving a file.  Quick save (0) saves the file immediately, trun‐
              cating 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.  When saving, the safe save (1) 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.  The safest method is
              create backups (2): a backup file is created before any changes  are  made.   You  can
              specify your own backup file extension in the dialog.  Note that saving twice will re‐
              place your backup as well as your original file.

       _editor_word_wrap_line_length_
              Line length to wrap at. Default is 72.

       _editor_backup_extension_
              Symbol to add to name of backup files. Default is "~".

       _editor_line_state_
              Show  state  line  of editor. Currently it shows current line number (in the future it
              might show things like folding, breakpoints, etc.). M-n toggles this option.

       _editor_visible_spaces_
              Toggle "show visible trailing spaces".  If editor_visible_spaces=1, they are shown  as
              '.'

       _editor_visible_tabs_
              Toggle "show visible tabs".  If editor_visible_tabs=1, tabs are shown as '<---->'

       _editor_persistent_selections_
              Do not remove block selection after cursor movement.

       _editor_drop_selection_on_copy_
              Reset selection after copy to clipboard.

       _editor_cursor_beyond_eol_
              Allow moving cursor beyond the end of line.

       _editor_cursor_after_inserted_block_
              Allow moving cursor after inserted block.

       _editor_syntax_highlighting_
              enable syntax highlighting.

       _editor_edit_confirm_save_
              Show confirmation dialog on save.

       _editor_option_typewriter_wrap_
              to be described

       _editor_option_auto_para_formatting_
              to be described

       _editor_option_save_position_
              Save file position on exit.

       _source_codepage_
              Symbol representation of codepage name for file (i.e. CP1251, ~ - default).

       _editor_group_undo_
              Combine  UNDO  actions  for several of the same type of action (inserting/overwriting,
              deleting, navigating, typing)

       _editor_wordcompletion_collect_entire_file_
              Search autocomplete candidates in entire file (1) or just from beginning  of  file  to
              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 aspell  package  (a  full
              list  can  be  obtained using 'aspell' utility).  Use **spell_language = NONE **to disable
              aspell support. Default value is 'en'. Option must be located in the [Misc] section.

       _editor_stop_format_chars_
              Set of characters to stop paragraph formatting. If one of those characters is found in
              the beginning of line, that line and all following lines  of  paragraph  will  be  un‐
              touched. Default value is "**-+*\,.;:&>**".

       _editor_state_full_filename_
              Show  full  path  name  in the status line. If disabled, only base name of the file is
              shown.

## MISCELLANEOUS
       The editor also displays non-us characters (160+).  When 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/ini file is missing.

       _/usr/share/mc/mc.lib_

              Global  settings  for  Midnight  Commander.  Settings  in  this file affect all users,
              whether they have ~/.config/mc/ini or not.

       _/usr/share/mc/syntax/*_

              The default system-wide syntax files for mcedit, 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 syn‐
              tax 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.

## AVAILABILITY
       The latest version of this program can be found at <http://ftp.midnight-commander.org/>.

## SEE ALSO
       [cooledit(1)](https://www.chedong.com/phpMan.php/man/cooledit/1/markdown), [mc(1)](https://www.chedong.com/phpMan.php/man/mc/1/markdown), [gpm(1)](https://www.chedong.com/phpMan.php/man/gpm/1/markdown), [terminfo(1)](https://www.chedong.com/phpMan.php/man/terminfo/1/markdown), [scanf(3)](https://www.chedong.com/phpMan.php/man/scanf/3/markdown).

## AUTHORS
       Paul Sheer (<psheer@obsidian.co.za>) is the original author of  Midnight  Commander's  internal
       editor.

## BUGS
       Bugs should be reported to <https://www.midnight-commander.org/>.

MC Version 4.8.30                           December 2024                                  [_MCEDIT_(1)](https://www.chedong.com/phpMan.php/man/MCEDIT/1/markdown)
