Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: pozzugno on January 05, 2011, 12:40:21 pm

Title: Adding new syntax highlights
Post by: pozzugno on January 05, 2011, 12:40:21 pm
When I open the window "Syntax hilighting", I can change the colours for a list of files type: C/C++, Matlab, HTML, ...
Each file type has a list of file extensions associated.

How can I add a new file type, like "Text" with extension "*.txt"? The Add button adds a colour theme, not a file type.
Title: Re: Adding new syntax highlights
Post by: BentFX on September 27, 2011, 11:05:50 am
The syntax highlighting is defined by "lexers." On Linux they're in /usr/share/codeblocks/lexers

Each lexer consists of two files. lexer_Name.xml and lexer_Name.sample.

The xml file defines the different syntax types and keywords. The sample file is the text that appears in the highlighted preview.

If you're interested in experimenting with creating new lexers the files can be created within your personal config. Again, assuming Linux, create the directory ~/.codeblocks/share/codeblocks/lexers and any files created within that directory will be loaded on C::B startup.

The wiki has information on creating lexers (http://wiki.codeblocks.org/index.php?title=Creating_a_custom_lexer_for_Code::Blocks_editor).

Good Luck & Have Fun!

(In actuallity, the xml file can point to any file to use as the sample text. It's just that lexer_Name.sample is the standard naming convention.)
(new reply to old post. Since the question still shows up in search it should be answered.)