#1571 setting indentUnit and fixing problems of it with Tern

Fix for #1571 
CodeMirror has two different settings for the indentation, we need to set both to the value wanted.
Also, this would cause some problems with Tern autocomplete (at least in development stage), so I create the Tern autocomplete function only if its settings are true, not just if the script is loaded (as it was before).