Let's look at crontab -e in Emacs vs Vim.


If I run crontab -e in Emacs:

EDITOR=emacs crontab -e

it looks like this:

enter image description here

So we basically have two colors. One for comments and one for crontab text.


In vim, the syntax highlighting is much richer:

  • comments

  • time/date

  • command

    EDITOR=vim crontab -e

enter image description here


Similar for neovim:

EDITOR=nvim crontab -e

enter image description here


Is there a way to get the richer syntax highlighting that vim provides for crontab in Emacs?

2 Answers 2


Have you set any theme? It seems like without any theme set, emacs doesn't show crontab-mode's (timewise) syntax highlighting.

enter image description here enter image description here

  • Ah... Ok... Let me try that. Thank you!
    – dharmatech
    Commented May 25 at 14:58
  • 1
    Yup, modus-vivendi theme did the trick. Thanks! I tried all the built-in themes and none of those showed different colors for the time fields.
    – dharmatech
    Commented May 25 at 15:34
  • 2
    It's a bug in the package, see my answer for a workaround to make it work with the default theme.
    – matteol
    Commented May 26 at 5:18
  • @matteol Ah, thank you!
    – dharmatech
    Commented May 27 at 17:42

There is a crontab-mode package in melpa.

You need to enable the melpa package repository,customizing the variable package-archives or adding the following to your emacs init file

(add-to-list 'package-archives
             '("melpa" . "https://melpa.org/packages/"))

then you can install it with

M-x package-install RET crontab-mode

The faces for the time fields are derived from ones defined in outline.elthat is not loaded by default. It's a little bug in the package, as a workaround you can add

(require 'outline)

to the emacs init file.

  • Looks like I already have it installed. list-packages shows: crontab-mode 20210715.133 installed Major mode for crontab(5)
    – dharmatech
    Commented May 25 at 7:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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