Friday, 23 January 2015

Edit Makefile in Intellij

My projects now tend to use a lot of different tooling.
eg: Vagrant, docker, Node, Bower, CURL, ANT, Maven, Gradle and a bunch of other custom tools that I have to remember how to use. Worse still we are moving to mass production, so I will need to remember them across projects.

To solve this, I have recently started using Makefiles to aggregate all the command line stuff. Now I can store the rarely used commands and port them from project to project without needing to go and look them up again.

Anyway, I need to edit a Makefile in Intellij IDEA.
Easy right...

Nope, I now keep getting:
Makefile:17: *** missing separator.  Stop.

FYI: The Cause of this error: MAKE requires a TAB at the start of each command line, but Intellij has converted all TABs to multiple Spaces. You can change the Makefile to use space as indents, but it looks horrible.

Anyway, I found a few solutions, and this is mainly to remind myself. But if you happen to find this post and it helps, please let me know, or worse if it fails, do please let me know in the comments, as I will look into it.

Firstly, install the C/C++ plugin from the plugin repositories.
This adds Makefile syntax checking and highlighting.

Second: to sort out the tab converting syntax problem, open your Makefile and then...
EDIT -> Convert Indents -> To Tabs

FYI: to see the Spaces/Tabs, I used "Show Whitepaces", by...
HELP -> Find Action -> "Whitepace"
which shows the characters in the active editor.


  1. 1 extra point: add keyboard shortcuts to the 2 whitespace commands, that way modifying a file when you have 4 spaces instead of tabs takes 1 second.