My code stays white


#1

Noob here,

I`m writing C, use Ubuntu, got the gpp-compiler package installed and the Syntax theme is the standard “One Dark” theme that came with atom.

thx


#2

I saved it as a .c file and now the text is colored, but why do I have to save the file in order to tell it to color the text? Is saving it as a .c file the only way to color the text?


#3

You can change the syntax manually for each tab without save, look for grammar selector in the command panel.
The shortcut for it should be Ctrl-shift-L

Saw a big topic about why grammar and not syntax, can’t find it anymore but seems to be some kind of troll-feeder in atom


#4

Because Atom has no way to know what type of code it is unless you tell it. You can manually select the language, you can add a shebang in the first line (for languages like Perl and shell scripts), or you can give it a file extension.

It’s not terribly difficult to guess that a file might be a PHP file or something weird like Lisp or Haskell, but it’s nearly impossible for an algorithm to tell the difference between C/C++/C# or CSS/Less/SCSS/Sass until you get a certain amount of code written that you include a keyword specific to that language. The amount of work it would take to support each language would be prohibitive for a free product, and it still wouldn’t highlight your code from the first keystroke.