Author Topic: Adding new syntax highlights  (Read 2872 times)

Offline pozzugno

  • Multiple posting newcomer
  • *
  • Posts: 39
Adding new syntax highlights
« 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.

Offline BentFX

  • Multiple posting newcomer
  • *
  • Posts: 18
    • BentFX
Re: Adding new syntax highlights
« Reply #1 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.

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.)
« Last Edit: September 27, 2011, 11:13:01 am by BentFX »
Whenever I go to Walmart I always request an intrusive pat-down from the greeter. It looks good on his resume, and it makes us all just a little bit safer.