The logo of Midnight Commander, licensed under the GPL3

Midnight Commander cheat sheet (part 2)

Notes published the
5 - 6 minutes to read, 1277 words
Categories: file association linux shell windows
Keywords: cheat sheet file association linux shell windows

Target audience

After the first introduction to mc, it is time to see how it can be customized to our needs.

Add and change keybindings

mc already configures a lot of keybindings, and yet I wished to add others, in particular some used by most, if not all, graphical file managers.

First, I’ve noticed that I would like to use the Del key for deleting files too. I know I can use F8, but no other program does, and often muscle memory kicks in and I find myself pressing Del.

Similarly, I believe that using Alt+ and Alt+ is more intuitive than Alt+u and Alt+y, and while we are at it, why not using Alt+ for switching to the parent directory?

The easiest way to change a keybinding is to create the file ~/.config/mc/mc.keymap, and copy from /etc/mc/mc.keymap the entries we are interested in. In this case, we should end up with the following file

Delete = f8

HistoryNext = alt-u
HistoryPrev = alt-y
CdParent = ctrl-pgup

For every action it is possible to define a set of keybindings separated by ;, thus after the changes the file should look like

Delete = f8; del

HistoryNext = alt-u; alt-kpright
HistoryPrev = alt-y; alt-kpleft
CdParent = ctrl-pgup; alt-kpup

Note that if we remove the original keybindings from ~/.config/mc/mc.keymap, those will not work anymore.

The files ~/.config/mc/mc.keymap and /etc/mc/mc.keymap are "merged" together by mc, but the entries in ~/.config/mc/mc.keymap completely override those of /etc/mc/mc.keymap.

Unfortunately, there seems to be no documentation about how the keys are named, at least the source code is easy enough to grasp.


Some folders are more important than others, or at least, we work in some folders more often than others.

mc has a built-in bookmark functionality, use Ctrl+X H, and mc will ask you to add the current directory to the hotlist.

You can then use Ctrl+\ to view all directories that have been added to the hotlist, and select which one you want to switch to.

Since on some keyboards, the \ character is unpractical to type (for example with the German keyboard layout you have to type AltGr+ß), I decided to assign a second, more practical, shortcut for accessing the hotlist:

HotList = ctrl-backslash; alt-b

case sensitivity

Alt+S is case-sensitive by default.

My files are mostly lowercase, but sometimes I need to work with files that are sent to me.

It is incredibly rare to have the same filename twice, with different cases, thus it makes sense to have a case-insensitive sorting and searching by default.

You can change those settings from mc itself

  • For left panel: F9 L S E

  • For right panel: F9 R S E

of by modifying the configuration files by hand:

[New Left Panel]

[New Right Panel]

For Alt+S, the setting is in F9 O P. The I for case insensitive, or D for the panel sort mode.


Alt+C opens the "Quick cd" menu, but I find using Ctrl+O faster because I can leverage the autocompletion functionalities of my shell.

It is possible to use autocompletion in the "Quick cd" menu too, but Alt+Tab ↹ is already used by the window manager for switching applications, and Esc+Tab ↹ is not really ergonomic. It would be great if it would be possible to use Tab ↹ directly; it should be, but does not seem to work on my machine.

I’ve added Ctrl+ as keybinding, it is better than Esc+Tab ↹, but still not ideal.

Complete = alt-tab; ctrl-space

Ctrl+ should work on all dialogs where Esc+Tab ↹ works, the main exception is when the panels are shown, as Ctrl+ is the keybinding for calculating the folder size (and I do not want to find an alternative for it).

File association

There are multiple ways to open a file.

With F3 (View), mc will open a file for viewing its content. By default, it uses the program mcview. Some file formats, like .pdf files, are converted to a sensible textual representation, and then rendered with mcview.

With F4 (Edit), mc will open a file for modifying its content. By default, it uses the program mcedit. In this case, non-textual files like PDF files are not converted.

With ↵ Enter (Open), mc might do one of the following things

  • try to execute the file if it is marked as executable

  • file like .pdf files, are opened with the associated graphical viewer (unless there is no graphical environment)

  • textual files are opened with $EDITOR, even if mc is configured to use the internal editor.

The behavior of those three actions can be modified by editing the file ~/.config/mc/mc.ext.ini. You might want to access it from mc itself (with F9 C E) so that it will populate the file with the default entries, and reload it after saving the changes.

By default, mc uses the wrapper script /usr/lib/mc/ext.d/ for supporting multiple file types.

Remote filesystems

mc can be used for accessing, writing, and reading files on remote machines. It introduced the FISH protocol, which should more or less work with any UNIX-like machine.

To open a connection to a remote machine, use F9 L H (or F9 R H for opening the connection on the right pane).

It seems to work reliably without further configurations, except on Android phones (at least with Termux).

Another alternative would be to use SFTP, in this case, use F9 L L (or F9 R L for opening the connection on the right pane).

For reference, OpenSSH uses by default SFTP since version 9, released in 2022, thus it should work on most up-to-date machines.

And it works on Android with Termux too.

It would be nice if mc supported MTP too, but it does not, I guess there is not much interest. It would have been better, but actually, I try to avoid all devices that use MTP if I have a chance.

Not because the support for most programs is scarce, but because by design it works badly.

User menu F2

The user menu can be customized as one desires.

Practical operations are to

  • execute an external program on the selected files or folders

  • archive the selected files

  • extract an archive

  • rename an image according to its metadata

and surely many more, depending on what you normally do with your files

mc comes with a predefined user menu, but I’ve never used it, it can be found at /etc/mc/, with an explanatory comment on how to write menu entries-

Here is what I’m using now

# do something on the current file/tagged files
# copied as-is from /etc/mc/
+ ! t t
@       Do something on the current file
        CMD=%{Enter command}
        $CMD %f
+ t t
@       Do something on the tagged files
        CMD=%{Enter command}
        for i in %t ; do
            $CMD "$i"

# open man page
# copied as-is from /etc/mc/
m       View manual page
        MAN=%{Enter manual name}
        %view{ascii,nroff} MANROFFOPT='-c -Tlatin1' MAN_KEEP_FORMATTING=1 man -P cat "$MAN"

# zip current file/selected files
+ ! t t
z       zip current file
        zip -r %f
+ t t
z       zip current files
        ZIPNAME=%{archive name}
        zip -r "$ZIPNAME" %t

Do you want to share your opinion? Or is there an error, some parts that are not clear enough?

You can contact me anytime.