How to add keywords (and change their colour) to CodeMirror?

I am currently using Brackets (code editor) to create some C source files. It uses CodeMirror to handle the syntax highlighting and I have been attempting now for a while to try and add keywords to it.

I managed to add ‘printf’ as a keyword by modifying this code here and adding ‘printf’ to the keywords.
However, I would like to change the colour of it and haven’t been able to do this. How could I do this?

Also, in the same way as line comments such as ‘//’ highlight the whole line, I would like to also do this if the line starts with ‘#’, changing the colour as well.

I am pretty sure I need to modify the ‘clike.js’ file to add the new keywords and some other .css file in order to change the colours but I just can’t seem to work it out.

Thanks for any help.

There is some text in the manual that describes how modes work. This blog post might also clarify some things. In general, some programming is required to change the behavior of a mode.

Im trying this code to handle from ‘#’ to the end of the line:

if (ch == "#") {
        stream.skipToEnd();
        return "comment";
}

I don’t ultimately want to set it as a comment, but just for test purposes I am here. However, it is still not being highlighted. Any idea why?

That should work (if it is reached).

Hmm, I’ve inserted that block into my code as follows:

function tokenBase(stream, state) {
    var ch = stream.next();
    if (hooks[ch]) {
      ...
    }
    if (ch == '"' || ch == "'") {
      ...
    }
    if (ch == "#") {
      stream.skipToEnd();
      return "comment";
    }
    if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
      ...
    }
    if (/\d/.test(ch)) {
      ...
    }
    if (ch == "/") {
     ...
    }
   ...

All of the other blocks seem to work fine, e.g. the last ‘if’ block that handles comments starting ‘/*’ or ‘//’.

Is there something I’m missing?
Also, will that block highlight the whole of this statement:

#pragma omp parallel

Thanks for your help.

I have solved it now. Thanks for the help.

Hello, can you share your solution please ?