Syntax highlighting for schematic and pcb files

One beauty of Kicad is that the schematic, pcb and library files are plaint text. For this reason I find myself more and more frequently using a text editor to manipulate these files.

While the files are easy to parse by the eye, adding some highlighting to the text could help navigating the files, e.g. like most editors highlight C code or other programming languages.

I’m currently using Kate as my main editor which uses XML files for highlight definitions and looking at sample files and the Kate documentation on this topic immediately gives me a headache …

Has anybody done some work on a highlight definition file for Kicad Schematic and/or PCB files?

I’d even go so far and ditch Kate for an editor with simpler highlighting definition syntax.

For the PCB and footprint files, the ones that are s-expressions, if you set the language to some sort of Lisp (Common Lisp, Scheme, Racket) you should be able to get decent syntax highlighting.

For Vim I just have:

au BufNewFile,BufRead *.kicad_mod,*.kicad_pcb set filetype=lisp
2 Likes

Notepad++ allows this to be done fairly easily, see https://github.com/Edditoria/markdown_npp for an example

2 Likes

Clojure is another s-expression LISP based language - and there is good, built-in support for it in Atom. ( https://atom.io). It works well out of the box – If you wanted a specific tweak I guess the grammar definition could be relatively easily modified to support specific Kicad options.

1 Like

Thank you all for the replies.

All LISP-based highlightings kind of work, but Kate’s highlighting for Clojure definitely does a good job out of the box.

I will take a look at Atom, it looks promising. The caveat is that there are only 64 bit linux binaries available, but maybe this is finally a good reason to brush up my production system with a 64 bit Linux :wink:

With current Kicad 6, 7, 8 formats, one can use a scheme language syntax highlighting. E.g. KDE Kate editor (and KrViewer as part of Krusader F3 viewer, F4 editor) supports scheme language.
See screenshot that also tells you where to associate kicad files with scheme syntax (add *.kicad_* to File extensions).
Nice is the unique colorizing of brackets in each nested (…)-expressions, which improve even readability of Kicad 6 & 7 formats.