mcedit

Softpanorama

May the source be with you, but remember the KISS principle ;-)
Home Switchboard Unix Administration Red Hat TCP/IP Networks Neoliberalism Toxic Managers
(slightly skeptical) Educational society promoting "Back to basics" movement against IT overcomplexity and  bastardization of classic Unix

Mcedit -- Midnight Commander�s Editor

News Midnight Commander Recommended Links Reference MC editor macros and user menu Mcedit keymap MC Macro variables mcview
OFM Standards OFM Standard 1999 OFM Standard 2004(OFM2004) OFM Book mcdiff MC Extension menu Usage of editor in Extension menu  
Orthodox Editors   PC-style super lightweight Unix editors  Cooledit MC History Sysadmin Horror Stories  Tips Humor Etc

Introduction

By default linux does not have decent Dos/Windows style editor installed. Midnight Commander contains usable, albeit DOS-style, not Windows-style full screen editor called mcedit. Please note that mcedit is also a tool for MineCraft game so searching for this name in Google is useless unless you prefix it with midnight commander.

Few people understand the mcedit has multiwindow capability. After you open it with you first file you can open another files using editor menu and then you can "cat and paste" fragments of text between them with ease using save selection to the clipfile feature (Edit/Save to clipfile) and then switch to the second window and paste from the clipfile in the point you need this selection. 

This editor has a great value as it is more convenient for writing small scripts then vi/vim. What's funny that for anything bigger then a dozen of lines making change via mcedit is often more convenient even for diehard vi/vim users like myself.  Two notable advantages are:

So diehard Unix command line users should take a notice :-)

Syntax highlighting is provided for both Perl and shell.  The editor itself somewhat reminds me FTE.  But it has different origin: it is based on the terminal version of cooledit - a standalone editor for X Window System.  Cooledit for X11 is much more powerful with Python extensibility. Mcedit is just a basic subset.

Mcedit (like cooledit) was developed by  Paul Sheer, one of the most talented developers who participated in Midnight Commander project. He definitely managed to put his mark on the key functionality of both MC and mcedit.

Due to its DOS-style behavior the editor can be used by most PC users with almost zero learning curve. Some highlights:

  1. F3 starts selection of line block. After that you can expand the block iether up or down. The second  F3 freeze the block and copy is into internal buffer. After that you can iether copy or move it with  F5 and F6 correspondingly.
     
  2. Undo. The editor provides multilevel undo capability (Ctrl-U)
     
  3. Top menu. Like all Dos/Windows-style editors, mcedit has the top menu. Like the top menu in OFM managers it is normally hidden, but can be made visible by pressing F9 key.
     
  4. The editor some unique capabilities due to existence of editor user menu (cedit.menu in mc version 4.8 renamed to mcedit.menu), including the ability to insert the content of the file instead of the current selected block or at the position of the cursor, if no block is selected (%b macro, see below).
     
  5. The editor supports macros (see below). To define a macro,
    • Press Ctrl-R and
    • Then type out the keys you want to be executed.
    •  Press Ctrl-R again when finished.
    • You can then assign the macro to any key you like by pressing that key.
    The macro is executed when you press Ctrl-A and then the assigned key. The macro is also executed if you press Meta, Ctrl, or Esc and the assigned key, provided that the key is not used for any other function.

    The macro commands are stored in the file ~/.mc/cedit/cooledit.macros. Do NOT edit this file if you are going to use macros again in the same editing session, because mcedit caches macro in memory. mcedit now overwrites a macro if a macro with the same key already exists, so you won't have to edit this file. You will also have to restart other running editors for macros to take effect.
     

  6. Built-in code formatting and spellchecking.
     
  7. There is a bottom menu that shows F-keys assignments. All items in this menu are clickable by mouse. No ability of "rolodex" -- to change the menu when you press  Ctrl-, Alt- and Shift- keys.
     
  8. Syntax highlighting. The editor provided user customizable syntax highlighting for all major scripting and programming languages (you can create your own highlighting scheme).

Here is an interesting discussion from Slashdot that points at some problems and advantages of mcedit (Midnight Commander Development Revived). If you read the whole thread not just selected messages listed below you probably will be surprised with the level of ignorance and misunderstanding about OFM demonstrated even in this brief exchange (I was). Anyway here is a half-dozen of related to mcedit messages from mc discussion on Slashdot: 

dbcad7

If you made a mistake in editing say your xorg.conf file, and upon reboot X will not restart.. mc is THE easiest editor to use.. bar none.. and it is easy to use for copying, renaming, moving files etc.. especially for those who don't often use the command line. It was standard to include it in all distros by default, and that was a good thing,. sadly not so much now .. If whatever distro I get doesn't have it, I always make sure I download it so it's there for emergencies.

 bruunb

Don't take this the wrong way, but I laughed out loud when I read you comment, I feel the same way about the MC editor (and any other for that matter :w appears often when I'm in a GUI program). CLI + VI(M) and you have all you need. Gnome/KDE is only for having multiple terminals open on one screen - great for log-watching when developing.

CronoCloud

I feel the same way about the MC editor (and any other for that matter :w appears often when I'm in a GUI program).

You can probably guess what happened when I used mc's editor. I moved the cursor where I wanted to edit and hit "i". And there it appeared, an "i", taunting me. Worse was some time back when I was using Notepad on Vista. I had finished editing and wanted to save and quit, and absentmindedly hit Esc and then did "ZZ", and wondered why it didn't save and quit and then noticed that "ZZ" sitting there. And I constantly try to middle click paste on Windows it's always tripping me up. Happens at least once, every time I use Windows.

I'm not a developer or admin so don't need to juggle a large number of terminal windows (and I don't use GNU screen) but I do use the mrxvt tabbed terminal.

bruunb

I never got that ZZ or :wq thing that I see a lot of coworkers use? I always use :w when I've made or finished a sentence and :x to quit and save. Rarely the :q! option. I think it comes from the old unstable network days at the dorm in the late '90... I must be getting old or something like that:x

graibeard

[Esc] 9 -> Options -> Configuration -> [] use internal menu (under 'Other options') Do that and it will probably default to vi (vim) ie:- the system default editor

mattack2

I realize it's mostly for file management, but I've seen others mention that it has a file editor. So is it easier than pico? Personally, I can't *stand* pico (and wouldn't use pine/alpine if I couldn't turn off pico and a bunch of other beginning-user-friendly things in it).. but it is pretty dang easy to use.

dbcad7

The editor in mc, is much like the dos editor from windows.. yeah it's pretty easy. Probably not a good programming editor, but very good for quick edits of config files.

Ash-Fox

It has syntax highlighting and a few other nifty features while being brain-dead simple.

Notable features of the editor

Versions and portability

Mcedit was improved in version 4.8 in comparison with version 4.6 of mc. So version 4.8 is a recommended version for those who want use the editor extensively.  But there is no easy way to upgrade SLES 10 and SLES 11 as well as RHEL 5 and 6 distributions which have mc-4.6.2.pre1-121.31.x86_64.rpm installed to version 4.8.x due to glib dependencies.  Debian, Ubuntu, and Cygwin do not have this problem. Actually Debian always was the distribution, the most friendly to open source packages. As of May 2018 it has 4.8.20 version available. This situation suggests that both mc and mcedit  have poor portability and need to be linked statically with their libraries on many distributions, which is a problem not limited to mc and mcedit, but a typical problem for complex Linux open source packages.

Current (as of May 2018) version of Cygwin has mc 4.8.20.  In this version user menu file previously called cedit.menu was renamed to mcedit.menu.

Invocation

The is not  a separate binary for mcedit. mcedit is just a symbolic link for mc. When invoked using this name mc opens the editor with the file specified.  There are two ways to invoke the editor:

Additional command line options

You can use several options with  mcedit (with the exception of option +lineno  those actually those are the same options that you can use with mc)

Key features

Hotkeys

Ctrl and Shift mean the same keyboard keys, Alt can also be single Esc press.

F3 Begin of text selection. Second press - end of text selection (toggle)
Shift+F3 Begin of block text selection
F5 Copy text selection
F6 Move text selection
F8 Delete text selection
Alt+i toggle 'Return does autoindent' option.
Alt+l Go to line by number.
Alt+q Insert literal. See table at bottom of this page.
Alt+t Sort of text in selection.
Alt+u Execute external command and insert output into cursor position
Ctrl+f Save selection into external file
Ctrl+k Delete chars to end of line
Ctrl+n Create new file (Like in Netscape)
Ctrl+s Toggle syntax highlighting
Ctrl+t Select text charset
Ctrl+u Undo
Ctrl+x Go to end of next word
Ctrl+y Delete line
Ctrl+z Go to start of previous word
Shift+F5 Insert external file content into cursor position
Alt+Enter Codejump dialog
Alt+- Move back into codejump (go to from function definition to function call)
Alt++ Move forward into codejump (go to from function call to function definition)
Alt+n Toggle number of lines
TAB If 'persistent blocks' option is on, then move selected text to right
Alt-TAB If 'persistent blocks' option is on, then move selected text to left
Shift+Arrows Text selection
Alt+Arrows Block text selection
Alt+Shift+- Toggle show visible tabs and trailing spaces

Here is a quote from Cooledit man page, the older brother of mcedit. It provides some additional useful information, although not all keys work the same way:

Movement keys:

Left left one char
Right right one char
Up up one line
Down down one line
Home beginning of line
End end of line
PgUp up one screen full
PgDn down one screen full
Ctrl-PgUp beginning of file
Ctrl-PgDn end file
Ctrl-Home beginning of page
Ctrl-End end of page
Ctrl-Left left one word
Ctrl-Right right one word
Ctrl-Up up one paragraph
Ctrl-Down down one paragraph
Meta/Alt-Up scroll up one line
Meta/Alt-Down scroll down one line

Highlight keys:
Shift with any of the above keys will highlight at the same time.

Column highlighting:
Holding down the Control key while using the mouse to highlight text,
will cause the highlighted text to be displayed in inverse colour. You
will be able to select columns (arbitrary rectangles) of text and
drag and drop them as usual.

Input History:
When editing an input line, Shift-Up or Shift-Down
will bring up a history of previous inputs.

Editing keys:
Delete delete char to the right
Backspace delete char to the left
Meta/Alt-Del delete to line end
Meta/Alt-Backspace delete to line begin
Meta/Alt-Right delete word to the right
Meta/Alt-Left delete word to the left
F5 copy highlighted text to cursor
F6 move highlighted text to cursor
F8 delete highlighted text
Ctrl-y delete line
Shift-Enter insert a newline
Enter insert a newline with auto indent (default)
Tab insert a tab (see options menu)
Insert toggle insert/overwrite
Ctrl-q quote - the next key pressed will be interpreted as a literal

Undo:
Ctrl-u
Ctrl-Backspace

File
Ctrl-F1 man page
F2 save
F12 or
Shift-F2 save as
Ctrl-o load

Ctrl-j jump to file under cursor
Ctrl-n new
Ctrl-f save highlighted text as
Shift-F5 or
F15 insert file at cursor

Mark:
F3 toggle highlight
Ctrl-b toggle highlight columns

Search and replace:
F7 search
F17 or
Shift-F7 search again
F4 replace
F14 or
Shift-F4 replace again

X Clipboard:
Ctrl-Ins copy to clipboard
Shift-Ins paste to clipboard
Shift-Delete cut to clipboard
Ctrl-Delete delete highlighted text
Meta/Alt-Ins insert from selection history

General:
F10 exit (current editor)
Ctrl-F3 new edit window
Shift-F3 new main window
Alt-F6 maximise the window
Ctrl-F6 window cycle
Ctrl-F10 exit application
Meta/Alt-x save all and exit
Ctrl-F2 save state of desktop
Ctrl-d insert date and time
Meta/Alt-l goto line number
Meta/Alt-F7 run make
Meta/Alt-t sort
Ctrl-r start/end record macro
Ctrl-a execute macro
Ctrl-p spell check highlighted text
Shift-F9 C formatter
Ctrl-Tab complete word
Meta/Alt-i insert unicode character

The bottom menu

You can learn mcedit keymap from the menu and from the bottom bar labels. There are five function keys that you need to be aware of to use mcedit:

Information line and upper menu

At the top of the editor there is an information like. It consists of four elements:

  1. Name of the file,
  2. Four flags in square brackets:
    1. Block selection,
    2. Modification(s) to the file are made
    3. Macro
    4. Overwrite mode is active instead of insert mode.
  3. Current line number
  4. Additional info

The editor has top menu which occupies the same space as information line and is normally hidden If you click anywhere in the information line with the mouse or press F9 and the information line will be replaced by the top menu.

It provides interesting capabilities, including the ability to insert the content of the file under cursor. Top menu has six tabs:

  1. File
    • Insert file -- allow insert file into position after cursor. cursor position will not change and will point to symbol before insertion point.
    • Copy to file. copy selected block to mcedit.clip
    • User menu -- allow to edit user menu
  2. Edit
    • Copy to clip file. Copy the current selection to clip file.
    • Paste from clip file. Paste the current selection after the current cursor position. The cursor position does not change.
  3. Search
    • Search, Search again and Replace.
    • Toggle bookmark, next bookmark, prev bookmark and flush bookmark.
  4. Command
    • Alt-L - goto the line
    • Alt-N -- put numbers column at left
    • Alt-B -- Go to matching bracket
    • Ctrl-S -- toggle syntax highlighting. Useful if with current background some elements are not visible or barely visible.
    • Working with macros
      • Ctrl-R -- Start/Strop recording macro
      • Delete macro
      • Record/Repeat last action. This is a kind of nameless action creation. First you can enter arbitrary keystrokes, then enter this menu item again and will be asked the number of repartitions. Them this nameless macro will be executed specified number of times.
  5. Format
    • Alt-U -- insert the result of execution of the script of pipe in the place before the cursor.
  6. Options
    • General. Among other things allow to replace tab with spaces and specify number of space per tab
    • Save options. allow to specify extension for backup files (default is ~)
    • Learn keys. Can correct some small "misunderstandings" connected with your terminal program. Generally useless.
    • Syntax highlighting. Allows to specify or modify existing syntax highlighting. For example if you prefer light background.
    • Menu file. Allows to edit either local or user menu:
      • ~/.cedit.menu ( local mcedit menu)
      • ~/.mc/cedit/menu ( user level mcedit menu). Location can be different, for example Cygwin uses ~/.config/mc/mcedit/menu

Working with blocks

Block selection mode is activated by pressing F3. After that you can select the block using arrow keys. Typing F3 again to "freeze" the block. At this point it is already copied to the clipboard. Now you can move the cursor to the point where you want to copy/move it and either click mouse on appropriate button at the bottom bar or press the appropriate keyboard shortcut (F5 - copy, F6 -- move F8 delete).

You can select block of text with mouse. But in version 4.8.20 this functionality works for selected emulators and environments. In Teraterm if you press F3 to freeze the block it is not copied and F5 does not copy anything. the only operation that words is duplication of selected text using F5 while test is still highlighted.

Undo/Redo

Simple "key for key" undo (Ctrl-U) and (in version 4.8) redo are available. Both functions are also available from top menu.

Cut and paste buffer to the file (cooledit.clip)

Editor has DOS-style "text block highlighting" mode (toggled by F3) in which arrow keys perform text highlighting. Any selection is copied to ~/.mc/cedit/cooledit.clip using copy of cut operation.

File ~/.mc/cedit/cooledit.clip, is very important as it can by preprocessed by pipe defined in User menu and then put back using paste operation. This is kind of poor man implementation of ! operation in vi/vim with additional twist due to existence of user menu.

Mouse highlighting works on linux console (and Cygwin console) and Teraterm. It also works in xterm.

Please note that mcedit doesn't share the clipboard with Teraterm, as Teraterm exists is different (Windows) operating environment and is connected to the Linux box via SSH or telnet.

User menu

The User menu ( F11 or F9/Options/menu ) displays commands contained in the first found menu file using three sources :

To edit user menu use F9/Options/menu or F11

You can use macros similar to panel user menu in editor user menu:

User has the ability to create his own templates and insert them into the text. Four templates are provided by default: Perl, shell and "universal" (I removed C-template to make quote less verbose):

#----------------------- Begin [perl] language template -----------------------
+ y Perl\ Program | f \.pl$
1       Author description header
        unset LANG
	unset LANGUAGE
	LC_ALL=
	MY_UID="`id | sed 's/^.*uid=\([^(]*\).*$/\1/'`"
	AUTHOR="`awk -F: '$3 == '$MY_UID' {print $5}' /etc/passwd`"
        cat >>%b <
        # Created at: `date`
        # Computer: `uname -n`
        # System: `uname -sr` on `uname -m`
        #   
        # Copyright (c) `date +%%Y` $AUTHOR  All rights reserved.
        #
        #----------------------------------------------------------------------
        # Configure section:
       
        #----------------------------------------------------------------------
        #
        # main()
       
        EOF

+ y Perl\ Program | f \.pl$
2       while ()
        cat < %b
        %iwhile() {
        %i}
        EOF

... ... ...
#----------------------- End [perl] language template -------------------------

#---------------------- Begin [shell] language template -----------------------


... ... ...

+ y Shell\ Script | f \.sh$
6       case
        NUMBER=%{ Enter number elements of case:}
        cat < %b
        %icase "\$" in
        EOF
        while [ "$NUMBER" -gt 0 ]
        do
        cat <> %b
        %i)
	%i    ;;
        EOF
        let NUMBER=$NUMBER-1   
        done
        cat <> %b
        %i*)
        %iesac
        EOF
... ... ...
#----------------------- End [shell] language template ------------------------
... ... ... 
#------------------------- Begin unknown template -----------------------------
s       #! /bin/sh
        echo "#! /bin/sh" >%b
p       #! /usr/bin/perl
        echo "#! /usr/bin/perl" >%b
a       Author description header
        unset LANG
	unset LANGUAGE
	LC_ALL=
	MY_UID="`id | sed 's/^.*uid=\([^(]*\).*$/\1/'`"
	AUTHOR="`awk -F: '$3 == '$MY_UID' {print $5}' /etc/passwd`"
        cat >>%b <
        Created at: `date`
        Computer: `uname -n`
        System: `uname -sr` on `uname -m`
       
        Copyright (c) `date +%%Y` $AUTHOR  All rights reserved.
        ----------------------------------------------------------------------
               
        EOF
#--------------------------- End unknown template -----------------------------

-------------------------------------------------------------------------------

#----------------------- Begin common section ---------------------------------
I       Insert `Changelog' string
        DATE="`date +%%Y-%%m-%%d`"
	MY_UID="`id | sed 's/^.*uid=\([^(]*\).*$/\1/'`"
	AUTHOR="`awk -F: '$3 == '$MY_UID' {print $5}' /etc/passwd`"
        EMAIL="<$REPLYTO>"
        echo "$DATE  $AUTHOR  $EMAIL" >%b

s       Invoke `shell'
	sh

m       view `man'
        MAN=%{Enter name of man:}
        TMPFILE=`mktemp ${MC_TMPDIR:-/tmp}/mcview.$MAN.XXXXXX` || exit 1
        man -Pcat $MAN >$TMPFILE
        mcview $TMPFILE
        rm -f $TMPFILE
               
i       Insert a out of command to cursor.
        CMD=%{ Enter command: }
    	eval $CMD > %b

o       Open bash to next free console
        open -s -- /bin/bash
#-------------------------- End of common section -----------------------------

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 ~/.mc/cedit/Syntax. If this file is missing, system-wide /usr/share/mc/syntax/Syntax is used. The file ~/.mc/cedit/Syntax is rescanned on opening of a any 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 to 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 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"

Ctags usage with mcedit

mcedit understands tags files created by etags or ctags commands. If there is no file TAGS code navigation would not work. In example, in case of exuberant-ctags for C language command will be:
ctags -e --language-force=C -R ./ 
There are three main key for navigation using ctags:

Macros

To define a macro, press Ctrl-R and then type out the keys you want to be executed. Press Ctrl-R again when finished. You can then assign the macro to any key you like by pressing that key. The macro is executed when you press Ctrl-A and then the assigned key. The macro is also executed if you press Meta, Ctrl, or Esc and the assigned key, provided that the key is not used for any other function. The macro commands are stored in the file ~/.mc/cedit/cooledit.macros. Do NOT edit this file if you are going to use macros again in the same editing session, because mcedit caches macro key defines in memory. mcedit now overwrites a macro if a macro with the same key already exists, so you won't have to edit this file. You will also have to restart other running editors for macros to take effect.

Formatting of code

F19 will format C, C++, Java or HTML code when it is highlighted. An executable file called ~/.mc/cedit/edit.indent.rc will be created for you from the default template. Feel free to edit it if you need.

Spell-checking

The editor supports spellchecking., You can spell check all text, selected fragment of word under cursor.


Top Visited
Switchboard
Latest
Past week
Past month


NEWS CONTENTS

Old News ;-)

[May 10, 2021] The Tilde Text Editor

Highly recommended!
This is an editor similar to FDE and can be used as external editor for MC
May 10, 2021 | os.ghalkes.nl

Tilde is a text editor for the console/terminal, which provides an intuitive interface for people accustomed to GUI environments such as Gnome, KDE and Windows. For example, the short-cut to copy the current selection is Control-C, and to paste the previously copied text the short-cut Control-V can be used. As another example, the File menu can be accessed by pressing Meta-F.

However, being a terminal-based program there are limitations. Not all terminals provide sufficient information to the client programs to make Tilde behave in the most intuitive way. When this is the case, Tilde provides work-arounds which should be easy to work with.

The main audience for Tilde is users who normally work in GUI environments, but sometimes require an editor for a console/terminal environment. This may be because the computer in question is a server which does not provide a GUI, or is accessed remotely over SSH. Tilde allows these users to edit files without having to learn a completely new interface, such as vi or Emacs do. A result of this choice is that Tilde will not provide all the fancy features that Vim or Emacs provide, but only the most used features.

News Tilde version 1.1.2 released

This release fixes a bug where Tilde would discard read lines before an invalid character, while requested to continue reading.

23-May-2020

Tilde version 1.1.1 released

This release fixes a build failure on C++14 and later compilers

12-Dec-2019

[Mar 05, 2020] Using Ctags with MC

Mar 05, 2020 | frankhesse.wordpress.com

the Midnight Commander's built-in editor turned out to be. Below is one of the features of mc 4.7, namely the use of the ctags / etags utilities together with mcedit to navigate through the code.

Code Navigation
Training
Support for this functionality appeared in mcedit from version 4.7.0-pre1.
To use it, you need to index the directory with the project using the ctags or etags utility, for this you need to run the following commands:

$ cd /home/user/projects/myproj
$ find . -type f -name "*.[ch]" | etags -lc --declarations -

or
$ find . -type f -name "*.[ch]" | ctags --c-kinds=+p --fields=+iaS --extra=+q -e -L-

')

me marginwidth=


After the utility completes, a TAGS file will appear in the root directory of our project, which mcedit will use.
Well, practically all that needs to be done in order for mcedit to find the definition of the functions of variables or properties of the object under study.

Using
Imagine that we need to determine the place where the definition of the locked property of an edit object is located in some source code of a rather large project.


/* Succesful, so unlock both files */
if (different_filename) {
if (save_lock)
edit_unlock_file (exp);
if (edit->locked)
edit->locked = edit_unlock_file (edit->filename);
} else {
if (edit->locked || save_lock)
edit->locked = edit_unlock_file (edit->filename);
}

me marginwidth=

To do this, put the cursor at the end of the word locked and press alt + enter , a list of possible options appears, as in the screenshot below.
image

After selecting the desired option, we get to the line with the definition.

[Mar 05, 2020] How to switch the editor in mc (midnight commander) from nano to mcedit?

Jan 01, 2014 | askubuntu.com

Ask Question Asked 9 years, 2 months ago Active 6 months ago Viewed 123k times

https://tpc.googlesyndication.com/safeframe/1-0-37/html/container.html


sdu ,

Using ubuntu 10.10 the editor in mc (midnight commander) is nano. How can i switch to the internal mc editor (mcedit)?

Isaiah ,

Press the following keys in order, one at a time:
  1. F9 Activates the top menu.
  2. o Selects the Option menu.
  3. c Opens the configuration dialog.
  4. i Toggles the use internal edit option.
  5. s Saves your preferences.

Hurnst , 2014-06-21 02:34:51

Run MC as usual. On the command line right above the bottom row of menu selections type select-editor . This should open a menu with a list of all of your installed editors. This is working for me on all my current linux machines.

, 2010-12-09 18:07:18

You can also change the standard editor. Open a terminal and type this command:
sudo update-alternatives --config editor

You will get an list of the installed editors on your system, and you can chose your favorite.

AntonioK , 2015-01-27 07:06:33

If you want to leave mc and system settings as it is now, you may just run it like
$ EDITOR=mcedit

> ,

Open Midnight Commander, go to Options -> Configuration and check "use internal editor" Hit save and you are done.

[Jun 18, 2018] Copy and paste text in midnight commander (MC) via putty in Linux

Notable quotes:
"... IF you're using putty in either Xorg or Windows (i.e terminal within a gui) , it's possible to use the "conventional" right-click copy/paste behavior while in mc. Hold the shift key while you mark/copy. ..."
"... Putty has ability to copy-paste. In mcedit, hold Shift and select by mouse ..."
Jun 18, 2018 | superuser.com

Den ,Mar 1, 2015 at 22:50

I use Midnight Commander (MC) editor over putty to edit files

I want to know how to copy text from one file, close it then open another file and paste it?

If it is not possible with Midnight Commander, is there another easy way to copy and paste specific text from different files?

szkj ,Mar 12, 2015 at 22:40

I would do it like this:
  1. switch to block selection mode by pressing F3
  2. select a block
  3. switch off block selection mode with F3
  4. press Ctrl+F which will open Save block dialog
  5. press Enter to save it to the default location
  6. open the other file in the editor, and navigate to the target location
  7. press Shift+F5 to open Insert file dialog
  8. press Enter to paste from the default file location (which is same as the one in Save block dialog)

NOTE: There are other environment related methods, that could be more conventional nowadays, but the above one does not depend on any desktop environment related clipboard, (terminal emulator features, putty, Xorg, etc.). This is a pure mcedit feature which works everywhere.

Andrejs ,Apr 28, 2016 at 8:13

To copy: (hold) Shift + Select with mouse (copies to clipboard)

To paste in windows: Ctrl+V

To paste in another file in PuTTY/MC: Shift + Ins

Piotr Dobrogost ,Mar 30, 2017 at 17:32

If you get unwanted indents in what was pasted then while editing file in Midnight Commander press F9 to show top menu and in Options/Generals menu uncheck Return does autoindent option. Yes, I was happy when I found it too :) – Piotr Dobrogost Mar 30 '17 at 17:32

mcii-1962 ,May 26, 2015 at 13:17

IF you're using putty in either Xorg or Windows (i.e terminal within a gui) , it's possible to use the "conventional" right-click copy/paste behavior while in mc. Hold the shift key while you mark/copy.

Eden ,Feb 15, 2017 at 4:09

  1. Hold down the Shift key, and drag the mouse through the text you want to copy. The text's background will become dark orange.
  2. Release the Shift key and press Shift + Ctrl + c . The text will be copied.
  3. Now you can paste the text to anywhere you want by pressing Shift + Ctrl + v , even to the new page in MC.

xoid ,Jun 6, 2016 at 6:37

Putty has ability to copy-paste. In mcedit, hold Shift and select by mouse

mcii-1962 ,Jun 20, 2016 at 23:01

LOL - did you actually read the other answers? And your answer is incomplete, you should include what to do with the mouse in order to "select by mouse".
According to help in MC:

Ctrl + Insert copies to the mcedit.clip, and Shift + Insert pastes from mcedit.clip.

It doesn't work for me, by some reason, but by pressing F9 you get a menu, Edit > Copy to clipfile - worked fine.

[Jun 18, 2018] My Favorite Tool - Midnight Commander by Colin Sauze

Notable quotes:
"... "what did I just press and what did it do?" ..."
"... Underneath it's got lots of powerful features like syntax highlighting, bracket matching, regular expression search and replace, and spell checking. ..."
"... I use Mcedit for most of my day-to-day text editing, although I do switch to heavier weight GUI-based editors when I need to edit lots of files at once. ..."
Jun 18, 2018 | software-carpentry.org

I've always hated the Vi vs Emacs holy war that many Unix users like to wage and I find that both editors have serious shortcomings and definitely aren't something I'd recommend a beginner use. Pico and Nano are certainly easier to use, but they always a feel a bit lacking in features and clunky to me.

Mcedit runs from the command line but has a colourful GUI-like interface, you can use the mouse if you want, but I generally don't.

If you're old enough to have used DOS, then it's very reminiscent of the "edit" text editor that was built into MS-DOS 5 and 6, except it's full of powerful features that still make it a good choice in 2018. It has a nice intuitive interface based around the F keys on the keyboard and a pull-down menu which can be accessed by pressing F9 .

It's really easy to use and you're told about all the most important key combinations on screen and the rest can all be discovered from the menus. I find this far nicer than Vi or Emacs where I have to constantly look up key combinations or press a key by mistake and then have the dreaded "what did I just press and what did it do?" thought.

Underneath it's got lots of powerful features like syntax highlighting, bracket matching, regular expression search and replace, and spell checking.

I use Mcedit for most of my day-to-day text editing, although I do switch to heavier weight GUI-based editors when I need to edit lots of files at once. I just wish more people knew about it and then it might be installed by default on more of the shared systems and HPCs that I have to use!

[Jun 17, 2018] Midnight Commander Guide

Jun 17, 2018 | www.nawaz.org

Selecting Text

  • {F3} to select some text, {F3} again to stop selecting.
    • {F5} to copy selected text elsewhere
    • {F8} to delete selected text

images/editmark.png

  • {Ctrl-u} to undo
  • {Alt-r} to redo
  • Clipboard:
    • {Ctrl-Ins} to copy
    • {Shift-Del} to cut
    • {Shift-Ins} to paste
3.2.3 Navigation
  • Text
    • {Alt-b} to jump to matching bracket, brace or parenthesis
    • {Alt-k} to bookmark line
    • {Alt-j} and {Alt-i} to navigate to next/previous bookmark
    • {Alt-o} to clear bookmarks
    • {Alt-l} to jump to line
    • {Alt-n} to display line numbers (see image on right)
  • Image

    images/editlines.png

3.2.4 Replacing Text
  • {F4} to replace text

images/editreplace.png

  • {F7} to search -- same dialog as with viewing
3.2.5 Saving
  • {F2} to save the current file
  • {F12} to save as a new file:

images/editsaveas.png 3.2.6 Syntax Highlighting

  • Supports syntax highlighting:

images/edithighlight.png

  • {Ctrl-s} to enable if not already enabled
3.2.7 More Options
  • Text
    • {F9} to get a drop down menu
    • Lots of goodies in the menus
  • Image

    images/editmenu.png

3.2.8 Some Comments about Editing
  • I'm impressed with how many people I've met who regularly use the editor, but have never heard of Midnight Commander.
    • It can be launched by typing mcedit on the command line.
  • I use it mostly for quick and dirty edits.
  • You can make an external editor your default:
    • From the main menu, Options , and then Configuration lets you disable the internal editor.

[Jun 13, 2018] Opening editor in another screen or tmux window

Jun 13, 2018 | www.queryxchange.com

by user2252728 Last Updated May 15, 2015 11:14 AM


The problem

I'm using tmux and I want MC to open files for editing in another tmux window, so that I can keep browsing files while editing.

What I've tried

MC checks if EDITOR variable is set and then interprets it as a program for editing, so if I do export EDITOR=vim then MC will use vim to open files.

I've tried to build on that:

function foo () { tmux new-window "vim $1"; }
export EDITOR=foo

If I do $EDITOR some_file then I get the file open in vim in another tmux windows - exactly what I wanted.

Sadly, when I try to edit in MC it goes blank for a second and then returns to normal MC window. MC doesn't seem to keep any logs and I don't get any error message.

The question(s)

  • Do you know what I'm doing wrong?
  • Do you have a usable workaround for what I want?
  • Should I create a feature request/bug for MC?
Tags : midnight-commander

Answers 1
You are defining a shell function, which is unknown for mc when it is trying to start the editor.

The correct way is to create a bash script, not a function. Then set EDITOR value to it, for example:

$ cat ~/myEditor.sh
#!/bin/sh
tmux new-window "vim $1"

export EDITOR=~/myEditor.sh

[Jun 13, 2018] Mcedit is actually a multiwindow editor

Opening another file in editor will create the second window. You can list windows using F9/Window/List\
That allows to copy and paste selections to different files while in editor
Jun 13, 2018 | www.unix.com

Many people don't know that mc has a multi-window text-editor built-in (eerily disabled by default) with macro capability and all sorts of goodies. run

mc -e my.txt

to edit directly.

[Mar 14, 2016] Macros in McEdit

To define a macro, press Ctrl-R and then type out the keystrokes you want to be executed..
Press Ctrl-R again when finished..
You can then assign the macro to any key you..
        like by pressing that key..
The macro is executed  by: Ctrl-A and then the assigned key.
===========
The simple example is to delete all "=" [from current cursor - forward].
The <F4>=<Replace> function of mcedit is the basis of the macro.
So:
Ctrl-r
 <f4> = <ca. 9 tabs> o l <enter>
 <must key to remove prompt which Falsely announces '5 replacemnets made'>
Ctrl-r
=========

[Mar 14, 2016] Ctrl+w clears the editboxes and Meta+h triggers the history drop-down

[Jan 18, 2015] how can i create file in mc? shift+f4 not working

1/13/2015 | Andrew Samoilov
Hello,

Use F9 - Options - Learn Keys.

P.S. If Shift-F4 is move file for you, use Shift-F2

On Mon, Jan 12, 2015 at 3:30 PM, Mike Smithson <[email protected]> wrote:
 Message: 2
Date: Wed, 24 Dec 2014 20:47:07 +0600
From: "Igor" 
To: [email protected]
Subject: error or i don't understend some thing
Message-ID:
        <CANxHswzE4u0Ty_f-oXSsmSozKUWHtYY2PLVoa9tViHdRC-
[email protected]>
Content-Type: text/plain; charset="utf-8"

hello, my name is Igor i have a question

how can i create file in mc? shift+f4 not working

now i using echo > flie.name in terminal mode(ctrl+o)

mc version 4.8.11

os ubuntu 14.04


shift+F4 is "move file" for me. If I want to edit a new file
I type "vim file" and hit enter. After that F4 will edit it if
it exists. "touch file" will also create new empty file (easier
to type than "echo > file).

--
Peace and Cheer

[Nov 05, 2012] Mcedit allows to edit many files in one mcedit window 4.8.4 � Midnight Commander

  • Multieditor: allow edit many files in one mcedit window (#2261, #2839)

    It would be nice if editor could open several files simultaneously in one window. Window could be split up vertically or horizontally. And it would be perfect if one could use copy/move/paste functions (F5/F6) between these files without using intermediate clipboard file ~/.mc/mcedit/cooledit.clip

  • Aspell support for spell check (#2788)

Internal editor's bookmarks are persistent now 4.7.5 � Midnight Commander

Internal editor's bookmarks are persistent now and not lost after exit from the editor. They are saved in ~/.mc/filepos file (#2287)

doc-editor-actions � Midnight Commander

d>
Command default hotkey
No-Command Empty action
Ignore-Key Empty action
BackSpace Deleting the character to the left of the cursor
Delete Deleting the character to the right of the cursor
Enter New line
Page-Up move up by one page
move down by one page
Left move left by one character
Right move right by one character
Word-Left move left by one word
Word-Right move right by one word
Up move up by one line
Down move down by one line
Home move to begin of line
End move to end of line
Tab tabulation
Undo Undo operation
Beginning-Of-Text move to begin of text
End-Of-Text move to end of text
Scroll-Up scroll up
Scroll-Down scroll down
Return ???Return???
Begin-Page move to begin of screen
End-Page move to end of screen
Delete-Word-Left Deleting the word to the left of the cursor
Delete-Word-Right Deleting the word to the right of the cursor
Paragraph-Up move up by one paragraph
Paragraph-Down move down by one paragraph
Save save current file
Load open file
New create new file
Save-as save current file with another name
Mark mark of text
Copy copying of marked text
Move moving of marked text
Remove deleting of marked text
Unmark unmark of text
Save-Block save marked text into file
Column-Mark vertical mark of text
Find call of 'search' dialog window
Find-Again continue search
Replace call of 'replace' dialog window
Replace-Again continue replace
Complete-Word autocompletions of words
Insert-File insert text from file
Exit Exit from editor
Toggle-Insert toggle insert/override edit mode
Help call of help window
Date insert current date
Refresh refresh screen
Goto Go to line
Delete-Line delete current line
Delete-To-Line-End delete from cursor position to end of line
Delete-To-Line-Begin delete from cursor position to begin of line

Man-Page

Sort Sorting of marked text

Mail

Cancel cancel action

Complete

Paragraph-Format formatting of paragraphs

Util Type-Load-Python

Find-File call 'file search' dialog windos

Ctags

Match-Bracket search paired brackets

Terminal Terminal-App ExtCmd

User-Menu call of user-defined menu

Save-Desktop New-Window Cycle Menu Save-And-Quit Run-Another Check-Save-And-Quit Maximize Begin-Record-Macro End-Record-Macro Delete-Macro

Toggle-Bookmark create/remove bookmark
Flush-Bookmarks delete all bookmarks
Next-Bookmark go to next bookmark
Prev-Bookmark go to previous bookmark

Page-Up-Highlight Page-Down-Highlight Left-Highlight Right-Highlight Word-Left-Highlight Word-Right-Highlight Up-Highlight Down-Highlight Home-Highlight End-Highlight Beginning-Of-Text-Highlight End-Of-Text_Highlight Begin-Page-Highlight End-Page-Highlight Scroll-Up-Highlight Scroll-Down-Highlight Paragraph-Up-Highlight Paragraph-Down-Highlight

XStore save marked text into ~/.mc/cedit/cooledit.clip file
XCut cut marked text and save into ~/.mc/cedit/cooledit.clip file
XPaste insert text from ~/.mc/cedit/cooledit.clip file

Selection-History Shell Select-Codepage Insert-Literal Execute-Macro Begin-or-End-Macro Ext-mode Focus-Next Focus-Prev Height-Inc Height-Dec Make Error-Next Error-Prev

Debug-Start Debug-Stop Debug-Toggle-Break Debug-Clear Debug-Next Debug-Step Debug-Back-Trace Debug-Continue Debug-Enter-Command Debug-Until-Curser

On Mon, 15 Oct 2012, Martin M�sa? wrote:

I do all my coding in mcedit, I usually have about 8 windows with mc opened
and copying between them is important to me. I usually use shift-mouse method.

When there was first release of MC where invisible characters ("Visible
trailing spaces" and "Visible tabs") was present I turned them off due this
mouse copy(-paste) problem.

Is it possible to detect shift-mousepress and switch them off automatically
and after copying switch them on again? Or do it in the copy buffer to avoid
redrawing of the screen on slow terminals?

I also turned off "Return does autoindent" also due (copy-)paste problem.
Maybe it also could be detected that paste was done (shift-middlepress) and
swith autoindent off for that moment...

Both these functions helps and I would use them, but if they breaks mouse
copy-paste which is important to me, I have switched them off. I use mouse
copy-paste about twice/hour, sometimes more.
Martin,

It seems to me that your problem is quite similar to mine, and I think 
that, unless someone comes up with an even better idea to solve the 
problem, you have a very good proposal for the solution. Of course, I 
would expect that neither of us are actually working on the MC code, so 
the implementation would have to be done by someone else. All that we can 
do is to try to get someone who does write the code to think about whether 
this is a feasible approach.

Theodore Kilgore

[Oct 28, 2012] Re MC editor customization

On Thu, 2010-12-09 at 06:38 -0800, Nikita1983 wrote:
> I want to customize tab key in mc editor so that it prints 4 spaces instead
> tab. How can I do it?

Yes. Check out editor options. -- Sincerely yours, Yury V. Zaytsev

[Oct 22, 2012] Text editors - mcedit

Feb 5, 2005 | JNRowe

Warning

Some of the mcedit features are not available if started from the command line, for example the F11 user menu. So when in doubt always start it internally from mc.

... ... ...

One of the best features of mcedit in my opinion is the fact most of the commands you may want to use are external. For example, pressing F19 (which you may need to press S-F9 to use depending on your keyboard and terminal setup) will reformat a file for you based on the contents of ~/.mc/cedit/edit.indent.rc. You can add support for XML reformatting just by editing that file, my particular entry for xml-style files is as follows:

xml|xsl|gdi)
   xmllint --format $2 | asc2xml | unexpand --first-only -t 2 >$2.tmp
   [ -s $2.tmp ] && mv $2.tmp $2 || rm $2.tmp ;;

The list of supported syntax highlighting is impressive, and adding support for more syntax files is a simple enough task. The format of the syntax files is described fully and generally easy to learn, even if apparently a little strange at first.

It also features word completion in the editor, type part of a word followed by Alt-Tab and the word will complete. A nice advantage when editing XML files with the enormous repetition that normally involves.

Like every command line tool it needs to support transparency for my candy needs to be met, and sure enough it does. My personal MC_COLOR_TABLE consists of the following to use nice transparent backgrounds in the editor. export MC_COLOR_TABLE=editnormal=,default globally in the environment, or from the command line with mcedit -C editnormal=,default: to only set it for a single instance.

[Oct 05, 2012] Midnight Commander Editor - Eclipse Color Themes

[Oct 02, 2012] Configuring mc (midnight commander) for file editing

09-17-2008| linuxquestions.org

sanjay.krk

Rep: Configuring mc (midnight commander) for file editing

--------------------------------------------------------------------------------

Hi All, I am using Fedora 7 with mc (midnight commander) as file manager. Every time I am inside mc and I have to open a file for editing, I have to press F4 (or choose edit from menu) for opening the file.

I want to configure it such that I can open the file just by pressing "Enter" after selecting the file names by arrow keys. Further I want the default editor to be vi or vim.

I will appreciate any pointers.

norobro

Rep: Take a look at the file mc.ext

On my machine it resides in /usr/local/share/mc

but I compiled MC from source so it could be elsewhere on your system.

For example to open .cpp files with VI the entry is:

regex/\.(C|cc|cpp)$
   Open=%var{EDITOR:vi} %f 

sanjay.krk

Thanks a lot, All! Modifying the bindings file worked.

I added "vi" as default (right at the bottom).

Cooledit Integrated Development Environment

1.8 What is Python and its relevance to Cooledit?
Python is an object orientated scripting language. (It can be compared to Java but has a much more elegant and intuative design.) It has the most succinct, sensable and readable syntax of any other programming language whether interpreted or compiled. It suites rapid application development (RAD) because it is easy to learn, because Python applications are easy to maintain, and because it is simply takes less time to do anything in Python than with anything else. In the same way that Emacs uses lisp for writing extensions, and Nedit has a macro programming language, Cooledit now can be custom programmed with Python. This is an extremely powerful addition, since all of Python's many extensions are available to Cooledit. The Python home page is http://www.python.org/ Cooledit requires Python version 1.5

SYNTAX HIGHLIGHTING (in cooledit) by Paul Sheer ([email protected])

SYNTAX HIGHLIGHTING

As of version 3.6.0, cooledit has syntax highlighting. This means that keywords and contexts (like C comments, string constants, etc) are highlighted in different colours. The following section explains the format of the file ~/.cedit/syntax.

The file ~/.cedit/syntax is rescanned on opening of a any 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 to what colour. The file is also divided into sections, each beginning with a line with the file command, followed by a regular expression. The regular expression dictates the file name that that set of rules applies to. Following this is a description to be printed on the left of the editor window explaining the file type to the user. A third optional argument is a regular expression to match the first line of text of the file. If either the file name matches, or the first line of text, then those rules will be loaded.

A section ends with the start of a new 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 region within a C style comment (i.e. between /* and */) has its own colour. This is a context, although it will have 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

context default

keyword whole if 24

keyword whole else 24

keyword whole for 24

keyword whole while 24

keyword whole do 24

keyword whole switch 24

keyword whole case 24

keyword whole static 24

keyword whole extern 24

keyword { 14

keyword } 14

keyword '*' 6

# C comments

context /\* \*/ 22

# C preprocessor directives

context linestart # \n 18

keyword \\\n 24

# C string constants

context " " 6

keyword %d 24

keyword %s 24

keyword %c 24

keyword \\" 24

Each context starts with a line of the form:

context [exclusive] [whole|wholeright|wholeleft] [linestart] delim [linestart] delim [foreground] [background]

One exception is the first context. It must start with the command

context default [foreground] [background]

or else cooledit will return an error.

The linestart option dictates that delim must start at the beginning of a line.

The whole option tells that delim must be a whole word. What constitutes a whole word are a set of characters that can be changed at any point in the file with the wholechars command. The wholechars command at the top just sets the set exactly to its default and could therefore have been omitted. To specify that a word must be whole on the left only, you can use the wholeleft option, and similarly on the right. 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]

Context or keyword strings are interpreted so that you can include tabs and spaces with the sequences \t and \s. Newlines and the \ are specified with \n and \\ respectively. Since whitespace is used as a separator, it may not be used explicitedly. Also, \* must be used to specify a *. The * itself is a wildcard that matches any length of characters. For example,

keyword '*' 6

colours all C single character constants green. You could also have used

keyword "*" 6

to colour string constants, except that the matched string may not cross 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 24

This line defines a keyword containing the \ and newline characters. Because keywords have a higher precedence than context delimiters, this keyword prevents the context from ending at the end of a line if the line ends in a \ thus allowing C preprocessor directive to continue across multiple lines.

The colours themselves are numbered 0 to 26 and are explained below in FURTHER BEHAVIORAL OPTIONS. You can also use any of the named colors specified in /usr/lib/X11/rgb.txt, though only one word versions of them. It is better to stick to the numerical colors to limit use of the color palette.

Comments may be included on a line of there own and begin with a #.

Because of the simplicity of the implementation, there are a few intricacies that will not be coped 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 imagination. If you can't 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 expression 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 can't cope with. Also remember that the aim of syntax highlighting is to make programming less prone to error, not to make code look pretty.

Re Cooledit

Jul 9, 1999 | linux.org.za

Dr R Paskaramoorthy

I use Paul Sheer's cooledit program to process Latex files and it is
certainly one of the best editors available for the Linux community.
I am particularly impressed by the option in the program that allows
to create new scripts and edit existing ones. To run Latex, they are
certainly handy.

I have a couple of questions:

1. Is it possible to change the background and foreground colors?

2. Is it also possible to change the default font?

There is nothing wrong with the default ones. It is just that my eyes
are not what they used to be.

Finally, I think that the program is very impressive. If one or
perhaps two buttons could be added to run Latex and Xdvi, it will
be even more attractive to the Latex users.

Cheers
Moorthy

PS: One more question. When I load one of my .tex files in cooledit
or xemacs, a ^M character is displayed at the end of every line. The
files were originally created and edited in Win95/98. Is there any
way to get rid of them. I have over 500 such files and editing them one
by one is not an option.

Berend De Schouwer

for FILE in `ls` 
   do 
      cp $FILE /tmp/some-temp-file 
      cat /tmp/some-temp-file | tr -d "\r" > $FILE 
   done	
Note: If it breaks, you are going to get the first file 500 times :)

Recommended Links

Google matched content

Softpanorama Recommended

Top articles

[May 10, 2021] The Tilde Text Editor Published on May 10, 2021 | os.ghalkes.nl

Sites

Mcedit

Internal

Reference

mcedit is a link to mc, the main Midnight Commander executable. Executing Midnight Commander under this name requests staring the internal editor and opening the file specified on the command line. The editor is based on the terminal version of cooledit - standalone editor for X Window System.

Options

+lineno
Go to the line specified by number (do not put a space between the + sign and the number).
-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>:<keyword>= ...
Specify a different color set. See the Colors section in mc(1) for more information.
-d
Disable mouse support.
-f
Display the compiled-in search path for Midnight Commander data files.
-t
Force using termcap database instead of terminfo. This option is only applicable if 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 full screen editor. It can edit files up to 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 replace (and our own scanf-printf search and replace); shift-arrow text highlighting (if supported by the terminal); insert-overwrite toggle; word wrap; autoindent; tunable tab size; syntax highlighting for various file types; and an option to pipe text blocks through shell commands like indent and ispell.

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 ~/.mc/cedit/cooledit.clip, Shift-Ins pastes from ~/.mc/cedit/cooledit.clip, Shift-Del cuts to ~/.mc/cedit/cooledit.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 Alt-Tab or Escape Tab) completes the word under the cursor using the words used earlier in the file.

To define a macro, press Ctrl-R and then type out the keys you want to be executed. Press Ctrl-R again when finished. You can then assign the macro to any key you like by pressing that key. The macro is executed when you press Ctrl-A and then the assigned key. The macro is also executed if you press Alt, Ctrl, or Esc and the assigned key, provided that the key is not used for any other function. The macro commands are stored in the file ~/.mc/cedit/cooledit.macros. Do NOT edit this file if you are going to use macros again in the same editing session, because mcedit caches macro key defines in memory. mcedit now overwrites a macro if a macro with the same key already exists, so you won't have to edit this file. You will also have to restart other running editors for macros to take effect.

F19 will format C, C++, Java or HTML code when it is highlighted. An executable file called ~/.mc/cedit/edit.indent.rc will be created for you from the default template. Feel free to edit it if you need.

C-p will run ispell on a block of text in a similar way. The script file will be called ~/.mc/cedit/edit.spell.rc.

If some keys don't work, you can use Learn Keys in the Options menu.

Code Navigation

mcedit can be used to navigation through code with tags files created by etags or ctags commands. If there is no file TAGS code navigation would not work. In example, in case of exuberant-ctags for C language command will be:

ctags -e --language-force=C -R ./ 

Alt-Enter show list box to select item under cursor (cusor should stand at end of word).

Alt-Minus where minus is symbol "-" go to previous function in navigation list (like a browser Back).

Alt-Equal where equal is symbol "=" go to next function in navigation list (like a browser Forward).

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 ~/.mc/cedit/Syntax. If this file is missing, system-wide /usr/share/mc/syntax/Syntax is used. The file ~/.mc/cedit/Syntax is rescanned on opening of a any 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 to 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 applied 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 [foreground] [background]

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

context default [foreground] [background]

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]

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 multiple 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 keywords are matched before the context delimiters, this keyword prevents the context from ending at the end of the lines that end in a backslash, thus allowing C preprocessor directive to continue across multiple lines.

The p brown, yellow, blue, brightblue, magenta, brightmagenta, cyan, brightcyan, lightgray and white. 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) for supported cooledit colors.

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

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 imagination. 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 expression 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.

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 now be set from the editors options dialog box. See the Options menu. The following options are defined in ~/.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 is 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 space. Rather insert spaces (ascii 20h) 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 inserted.
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 by immediately, truncating the disk file to zero length (i.e. erasing it) and the 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 an 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). Where 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 replace your backup as well as your original file.
editor_word_wrap_line_length
line length to wrap. 72 default.
editor_backup_extension
symbol for add extension to name of backup files. Default "~".
editor_line_state
show state line of editor now it show number of file line (in future it can show things like folding, breakpoints, etc.). Alt-n toglle this option.
editor_visible_spaces
Toggle show visible trailing spaces (TWS), if editor_visible_spaces=1 TWS showed as '.'
editor_visible_tabs
Toggle show visible tabs, if editor_visible_tabs=1 tabs showed as '<---->'
editor_persistent_selections
Do not remove block selection after moving the cursor.
editor_cursor_beyond_eol
Allow moving cursor beyond the end of line.
editor_syntax_highlighting
enable syntax highlighting.
editor_edit_confirm_save
show confirm 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_wordcompletion_collect_entire_file
Search autocomplete candidates in entire of file or just from begin of file to cursor position (0)

Miscellaneous

You can use scanf search and replace to search and replace a C format string. First take a look at the sscanf and sprintf man pages to see what a format string is and how it works. Here's an example: suppose that you want to replace all occurrences of an open bracket, three comma separated numbers, and a close bracket, with the word apples, the third number, the word oranges and then the second number. You would fill in the Replace dialog box as follows:

Enter search string(%d,%d,%d)
Enter replace stringapples %d oranges %d
Enter replacement argument order3,2

The last line specifies that the third and then the second number are to be used in place of the first and second.

It is advisable to use this feature with Prompt On Replace on, because a match is thought to be found whenever the number of arguments found matches the number given, which is not always a real match. Scanf also treats whitespace as being elastic. Note that the scanf format %[ is very useful for scanning strings, and whitespace.

The editor also displays non-us characters (160+). When editing binary files, you should set display bits to 7 bits in the Midnight Commander options menu to keep the spacing clean.

Files

/usr/share/mc/mc.hlp

The help file for the program.

/usr/share/mc/mc.ini

The default system-wide setup for Midnight Commander, used only if
the user's own ~/.mc/ini file is missing.

/usr/share/mc/mc.lib

Global settings for the Midnight Commander. Settings in this file
affect all users, whether they have ~/.mc/ini or tml FKUS|Articles/introduction_to_orthodox_file_managers.shtml FKUS|Articles/introduction_to_orthodox_file_managers.shtml FKUS|Articles/introduction_to_orthodox_file_managers.shtml FKUS|Articles/introduction_to_orthodox_file_managers.shtml FHUS|Admin/social_problems_in_system_administration.shtml NHHS|http://emacswiki.org/emacs/Sunrise_Commander NHHS|http://www.nongnu.org/ratpoison/ FHUS|Utilities/screen.shtml NHSS|https://github.com/vitaut/captain-nemo FHUS|OFM/Standards/ofm_standard1999.shtml FHUS|OFM/Standards/ofm_standard1999.shtml NHHS|http://emacswiki.org/emacs/Sunrise_Commander FHUS|OFM/Paradigm/Ch04/mc.shtml FHUS|OFM/Paradigm/Ch05/file_commander.shtml FHUS|OFM/Paradigm/Ch05/far.shtml vti_cachedneedsrewrite:BR|false vti_cachedhasbots:BR|false vti_cachedhastheme:BR|false vti_cachedhasborder:BR|false vti_Alttags:VR|HTTP-EQUIV=Content-Language en-us HTTP-EQUIV=Content-Type text/html;\\ charset=windows-1252 vti_charset:SR|windows-1252 vti_language:SR|en-us h3>See Also

cooledit(1), mc(1), gpm(1), terminfo(1), scanf(3).

Authors

Paul Sheer ([email protected]) is the original author of the Midnight Commander's internal editor.

Bugs

Bugs should be reported to [email protected]

Referenced By

mcview(1)



Etc

Society

Groupthink : Two Party System as Polyarchy : Corruption of Regulators : Bureaucracies : Understanding Micromanagers and Control Freaks : Toxic Managers :   Harvard Mafia : Diplomatic Communication : Surviving a Bad Performance Review : Insufficient Retirement Funds as Immanent Problem of Neoliberal Regime : PseudoScience : Who Rules America : Neoliberalism  : The Iron Law of Oligarchy : Libertarian Philosophy

Quotes

War and Peace : Skeptical Finance : John Kenneth Galbraith :Talleyrand : Oscar Wilde : Otto Von Bismarck : Keynes : George Carlin : Skeptics : Propaganda  : SE quotes : Language Design and Programming Quotes : Random IT-related quotesSomerset Maugham : Marcus Aurelius : Kurt Vonnegut : Eric Hoffer : Winston Churchill : Napoleon Bonaparte : Ambrose BierceBernard Shaw : Mark Twain Quotes

Bulletin:

Vol 25, No.12 (December, 2013) Rational Fools vs. Efficient Crooks The efficient markets hypothesis : Political Skeptic Bulletin, 2013 : Unemployment Bulletin, 2010 :  Vol 23, No.10 (October, 2011) An observation about corporate security departments : Slightly Skeptical Euromaydan Chronicles, June 2014 : Greenspan legacy bulletin, 2008 : Vol 25, No.10 (October, 2013) Cryptolocker Trojan (Win32/Crilock.A) : Vol 25, No.08 (August, 2013) Cloud providers as intelligence collection hubs : Financial Humor Bulletin, 2010 : Inequality Bulletin, 2009 : Financial Humor Bulletin, 2008 : Copyleft Problems Bulletin, 2004 : Financial Humor Bulletin, 2011 : Energy Bulletin, 2010 : Malware Protection Bulletin, 2010 : Vol 26, No.1 (January, 2013) Object-Oriented Cult : Political Skeptic Bulletin, 2011 : Vol 23, No.11 (November, 2011) Softpanorama classification of sysadmin horror stories : Vol 25, No.05 (May, 2013) Corporate bullshit as a communication method  : Vol 25, No.06 (June, 2013) A Note on the Relationship of Brooks Law and Conway Law

History:

Fifty glorious years (1950-2000): the triumph of the US computer engineering : Donald Knuth : TAoCP and its Influence of Computer Science : Richard Stallman : Linus Torvalds  : Larry Wall  : John K. Ousterhout : CTSS : Multix OS Unix History : Unix shell history : VI editor : History of pipes concept : Solaris : MS DOSProgramming Languages History : PL/1 : Simula 67 : C : History of GCC developmentScripting Languages : Perl history   : OS History : Mail : DNS : SSH : CPU Instruction Sets : SPARC systems 1987-2006 : Norton Commander : Norton Utilities : Norton Ghost : Frontpage history : Malware Defense History : GNU Screen : OSS early history

Classic books:

The Peter Principle : Parkinson Law : 1984 : The Mythical Man-MonthHow to Solve It by George Polya : The Art of Computer Programming : The Elements of Programming Style : The Unix Hater�s Handbook : The Jargon file : The True Believer : Programming Pearls : The Good Soldier Svejk : The Power Elite

Most popular humor pages:

Manifest of the Softpanorama IT Slacker Society : Ten Commandments of the IT Slackers Society : Computer Humor Collection : BSD Logo Story : The Cuckoo's Egg : IT Slang : C++ Humor : ARE YOU A BBS ADDICT? : The Perl Purity Test : Object oriented programmers of all nations : Financial Humor : Financial Humor Bulletin, 2008 : Financial Humor Bulletin, 2010 : The Most Comprehensive Collection of Editor-related Humor : Programming Language Humor : Goldman Sachs related humor : Greenspan humor : C Humor : Scripting Humor : Real Programmers Humor : Web Humor : GPL-related Humor : OFM Humor : Politically Incorrect Humor : IDS Humor : "Linux Sucks" Humor : Russian Musical Humor : Best Russian Programmer Humor : Microsoft plans to buy Catholic Church : Richard Stallman Related Humor : Admin Humor : Perl-related Humor : Linus Torvalds Related humor : PseudoScience Related Humor : Networking Humor : Shell Humor : Financial Humor Bulletin, 2011 : Financial Humor Bulletin, 2012 : Financial Humor Bulletin, 2013 : Java Humor : Software Engineering Humor : Sun Solaris Related Humor : Education Humor : IBM Humor : Assembler-related Humor : VIM Humor : Computer Viruses Humor : Bright tomorrow is rescheduled to a day after tomorrow : Classic Computer Humor

The Last but not Least Technology is dominated by two types of people: those who understand what they do not manage and those who manage what they do not understand ~Archibald Putt. Ph.D


Copyright � 1996-2021 by Softpanorama Society. www.softpanorama.org was initially created as a service to the (now defunct) UN Sustainable Development Networking Programme (SDNP) without any remuneration. This document is an industrial compilation designed and created exclusively for educational use and is distributed under the Softpanorama Content License. Original materials copyright belong to respective owners. Quotes are made for educational purposes only in compliance with the fair use doctrine.

FAIR USE NOTICE This site contains copyrighted material the use of which has not always been specifically authorized by the copyright owner. We are making such material available to advance understanding of computer science, IT technology, economic, scientific, and social issues. We believe this constitutes a 'fair use' of any such copyrighted material as provided by section 107 of the US Copyright Law according to which such material can be distributed without profit exclusively for research and educational purposes.

This is a Spartan WHYFF (We Help You For Free) site written by people for whom English is not a native language. Grammar and spelling errors should be expected. The site contain some broken links as it develops like a living tree...

You can use PayPal to to buy a cup of coffee for authors of this site

Disclaimer:

The statements, views and opinions presented on this web page are those of the author (or referenced source) and are not endorsed by, nor do they necessarily reflect, the opinions of the Softpanorama society. We do not warrant the correctness of the information provided or its fitness for any purpose. The site uses AdSense so you need to be aware of Google privacy policy. You you do not want to be tracked by Google please disable Javascript for this site. This site is perfectly usable without Javascript.

Last modified: August, 19, 2019