[Kate] is it possible to add custom keywords to the syntax highloighter?

Hello! I’m using kate to edit C code and I’d like that keywords like pid_t, SIGINT, etc are colored instead of being plain white like the plain text. is this possible?

yes, but you will need to create your own syntax file or copy ours and extend it however you want. See Working with Syntax Highlighting

This is where the builtin syntax files live: Frameworks / Syntax Highlighting Engine · GitLab

1 Like

thanks! I was hoping for something already made, I’ll try to implement my own as soon as I can, and if satisfied with the result I’ll share it here

It is already made, you just need to copy our C syntax file and then add a couple of lines to highlight the extra words you have.

Oh and, don’t forget to bump the “version” at the top of the file. Otherwise Kate won’t pick up the new highlighting.

1 Like

Ohh this changes everything! Thank you very much!!

okay, I copied /usr/share/org.kde.syntax-highlighting/syntax-bundled/c.xml to $HOME/.local/share/org.kde.syntax-highlighting/syntax/c.xml and edited it to add the keywords I wanted, then changed the version from 18 to 180, restarted kate and… voilà! it works perfectly, thank you very much for your help!

1 Like