Automation of syntax in C


Hi guys,

for first I’d like to say, that I’m little bit new in programming, also in this forum and my English isn’t professional or something like that, so sorry for any fails about my English or rules for this forum :smiley:

So what’s my problem? I’d like to set up in setting, that when i press ctrl+n I want default the colors of code for C, because for now I am programming only in C :slight_smile: And would be perfect, if in this new file will be the basic part of code too.
For better notion I upload here screenshot of my imagine :smiley:


And one more detail with scanf("%s\n", ); - I think, that it will be better in this default setting scanf("%s\n", &); because new programmer can forgeting the & in the end and this can be good notification :stuck_out_tongue: Can you think, that is possible to change this, please? :slight_smile:


I understand why you think you want this, but I don’t believe that this is a good idea. I feel like the uncolored text motivates the user to save the file as quickly as possible, which is a good thing. If you want to do it anyway, you can add this to your

atom.workspace.observeTextEditors (editor) ->                # Whenever a new TextEditor opens,
  unless editor.getPath()                                    # if the file is unsaved,
    grammar = atom.grammars.grammarForScopeName("source.c")  # get the grammar for C
    editor.setGrammar(grammar)                               # and set it in the editor.

All of this is explained in Atom’s API documentation.

And would be perfect, if in this new file will be the basic part of code too.

It would be a piece of cake to expand the code above to insert text into the empty editor, or you could use Atom’s snippets functionality.