Recently I discover a power of MC to view/edit certain types of file. For example this:

    View=%view{ascii} tmp=%p; javap -c ${tmp%%.class}

from ~/.mc/bindings take me brief look for Java class methods/fields by pressing F3. But it is hard to look when all code use same colors. I would like to see keywords and types highlighted in some form.

Is it possible (and how) make user customization for syntax highlighting in build-in Midnight Commander editor/viewer (by regex)?


Syntax related files are stored in /usr/share/mc/syntax. These files are provided by the package management system. They could be edited as root, and it should work, but this would be a hack.

The correct solution is to copy /usr/share/mc/syntax/Syntax to your home directory: ~/.config/mc/mcedit/Syntax. (Note: old version could use other path e.g: ~/.mc/cedit) This file defines file types associations, and if it is present in your home directory, then it will override the default one. So it could be edited now.

For example if you want to add a syntax file for qwe extensions you should add these lines:

file ..\*\\.qwe$ qwe\sFile
include /home/username/.config/mc/mcedit/qwe.syntax

Note that include needs an absolute path, if the file is not located in /usr/share/mc/syntax. After that you should create and edit your qwe.syntax file based on the other ones.

| improve this answer | |

Can't say anything about colours, but the binding needs to be updated to view class files within a jar:

     View=%view{ascii} tmp=%f; xyxy=${tmp##*/}; javap -classpath ${tmp%/*.class} -c ${xyxy%.class}
| improve this answer | |
  • 1
    Sorry but you just copy what I write by myself (( – gavenkoa Oct 20 '12 at 17:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.