How do I make Emacs give me live feedback on my syntax?

Like, after I finish typing a line of code, how can I make it so that Emacs tells me if that line isn't using correct syntax?

For example, in Eclipse, it'll tell you before you compile when a line is not correct (in Java, at least). How can I mimic that behavior in Java, C, etc. for Emacs?


Running Emacs 24 in Terminal by the way. Installed via HomeBrew on OSX.

  • Typing a line of what? What syntax/language are you using? The question is not very clear. Please specify the behavior you are looking for. – Drew Oct 17 '15 at 22:30
  • I'm sorry, I meant for any language in general. For example, Eclipse does a syntax highlight for Java. (I'm doing C at the moment, but same concept). – CodeSammich Oct 17 '15 at 22:48
  • flycheck.org – mbork Oct 17 '15 at 23:09
  • It's not installing via MELPA. Keeps saying that the .el isn't found – CodeSammich Oct 17 '15 at 23:43
  • Nevermind! It's installed. Not really what it looked like on the website, sadly. – CodeSammich Oct 17 '15 at 23:46

Emacs has a built-in mode called FlyMake that can do this, provided you have a properly configured makefile. Turn flymake on with M-x flymake-mode. It runs an external command (by default make check-syntax) collects the errors and warnings and highlights the buffer appropriately. It works pretty well for C and with some effort can be configured for other languages.

There is also an external package Flycheck that you can install with M-x package-install flycheck. Turn it on with M-x flycheck-mode. With most languages it Just Works with no further configuration. You may need to install some external tool (for example pylint to check Python code).

| improve this answer | |
  • It's working, but it's not working as it should, in my opinion. It highlights the words so much that I can't even read them properly, in full screen. Also highlights some function names and variable types for who knows why. – CodeSammich Oct 18 '15 at 0:29
  • For flycheck you can customize the faces flycheck-warning and flycheck-error to change the highlighting. There are similar faces for flymake. A description of the error should appear in the minibuffer when you put the cursor over it. – erikstokes Oct 18 '15 at 0:47
  • I enabled flymake, intentionally misspelled a variable, intentionally misspelled a word in a comment. Nothing is highlighted. Any suggestions on how I can even begin to debug this? – par Apr 29 '19 at 10:44

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.