Zim - A Desktop Wiki

mail

How to edit the syntax-highlighting colors within code blocks made with Source View plugin ?

Preliminary : setup of the Source View plugin :

  1. Edit | Preferences | Plugins | Source View
  2. the page says :
    Broken dependencies for the Source View plugin, fixed in version 0.70.x (not yet packaged in Debian) :
    1. Get up-to-date .deb package here : https://zim-wiki.org/downloads/
    2. install it manually
  3. apt install --no-install-recommends libgtksourceview-3.0

How to edit colors of syntax-highlighted snippets ?

  1. This is all handled by libgtksourceview-3.0
  2. Languages are defined in /usr/share/gtksourceview-3.0/language-specs/language.lang.
    • each file is a collection of regular expressions defining/matching what is a string, a language keyword, a comment, an operator, ...
    • these files do NOT define colors
  3. styles are defined in /usr/share/gtksourceview-3.0/styles
    • I don't know where in Zim configuration or anywhere else is defined which styles file is used.
    • I tried editing classic.xml and it worked
  4. Before making changes, since my Zim notes are shared across computers, I had to integrate the styles file to my repo :

    stylesDirOriginal='/usr/share/gtksourceview-3.0/styles'; stylesDirCustom="$HOME/path/to/myZimNotebook/styles"; styleName='classic'; mkdir -p "$stylesDirCustom"; mv "$stylesDirOriginal/$styleName.xml" "$stylesDirCustom"; chown kevin: "$stylesDirCustom" "$stylesDirCustom/$styleName.xml"; ln -s "$stylesDirCustom/$styleName.xml" "$stylesDirOriginal/$styleName.xml"

  5. ... then edit colors
mail

How to edit the colors used for titles, links, ... ?

Copy /usr/share/zim/style.conf to ~/.config/zim/ and edit as you see fit. See the Config Files page for the syntax of this file. (source)

In more details :

I use Zim on several computers, hence the command lines to do things the same way everywhere .

  1. make your own copy of the settings file :

    zimConfigFile='style.conf'; personalSettingsFile="$HOME/.config/zim/$zimConfigFile"; distSettingsFile="/usr/share/zim/$zimConfigFile"; [ -f "$personalSettingsFile" ] || cp "$distSettingsFile" "$personalSettingsFile"

  2. my whole Zim notebook is versioned + shared with Git. This command moves the personal settings file into the notebook directory so that my notebook looks the same everywhere :

    zimNotebookBaseDirectory="$HOME/path/to/Zim/notebook"; mv "$personalSettingsFile" "$zimNotebookBaseDirectory"; ln -s "$zimNotebookBaseDirectory/$zimConfigFile" "$personalSettingsFile"