How to add custom color scheme to gedit-3.14.0

38,047

Solution 1

On my machine it seems gedit keeps its newly added themes at:

 ~/.gnome2/gedit/styles/

though I believe on some installations it is at:

 $HOME/.local/share/gedit/styles/

The original themes are (on my machine) at:

 /usr/share/gtksourceview-2.0/styles/


So the information below isn't particularly relevant, though I'll let it stay because it might help in some way.

From the documentation at: https://wiki.gnome.org/Projects/GtkSourceView/StyleSchemes

To install a style just place its XML file into a folder of the style search path.

GtkSourceView 2

A typical search path for GtkSourceView version 2 looks like:
        ~/.local/share/gtksourceview-2.0/styles/
        /usr/share/gnome/gtksourceview-2.0/styles/
        /usr/local/share/gtksourceview-2.0/styles/
        /usr/share/gtksourceview-2.0/styles/

If this does not work in your distribution you can find out your style search path with this python script. To run it you need the python bindings for GtkSourceView 2. In Debian-based distributions this is package python-gtksourceview2.

GtkSourceView 3

A typical search path for GtkSourceView version 3 looks like
        ~/.local/share/gtksourceview-3.0/styles/
        /usr/share/gnome/gtksourceview-3.0/styles/
        /usr/local/share/gtksourceview-3.0/styles/
        /usr/share/gtksourceview-3.0/styles/

Solution 2

You can find free themes here: https://wiki.gnome.org/Projects/GtkSourceView/StyleSchemes

  1. Find your theme and click download.

  2. An xml code will appear. Copy and it and open your text editor.

  3. Paste your xml code and save under xml format (name_of_your_theme.xml).

  4. In gedit select Edit->Preferences->Font & Colors then click on the "+" to add new themes.

  5. Choose your theme.

Solution 3

I've found a way to solve this problem:

  1. Open Ubuntu Software Center, search for gedit
  2. Add optional add-ons "A Set of gedit plugins for developers" & "Set of plugins for gedit"
  3. Enable the addons from gedit preferences, especially "Color Scheme Editor"
  4. Edit your own color scheme for gedit and save.

But I still got a question: I search the /usr/share/gtksourceview-3.0/styles/ folder, but can not find my own color scheme file that I just created. Where did the system store the color scheme file?

Share:
38,047

Related videos on Youtube

Seth Lee
Author by

Seth Lee

Updated on September 18, 2022

Comments

  • Seth Lee
    Seth Lee over 1 year

    I change the xml file in the /usr/share/gtksourceview-3.0/styles/ but it didn't work, and when I want to add my own scheme through the Preference --> Font&Color and it replied that

    "The selected color scheme cannot be installed".

    what's wrong with it?

    And I noticed that I have already change the gedit color scheme to "oblivion" and font site to 14, but when I start gedit from terminal using sudo gedit, the open window falls back to the default setting.

    How can I fix this?

  • WillC
    WillC almost 7 years
    I downloaded Dracula, added it to gedit through Edit -> Preferences -> Fonts & Colors -> + , and the dracula.xml file ended up in ~/.local/share/gedit/styles/
  • kurdtpage
    kurdtpage almost 7 years
    FYI I'm using gedit v3.18.3 on Linux Mint 18 and the 2 developers plugins installed properly via Synaptic Package Manager, but the editor does not save
  • Mikko Rantalainen
    Mikko Rantalainen over 2 years
    I had to use "install new style" button at the bottom even after adding file to ~/.local/share/gtksourceview-3.0/styles/ to make it appear in the list without restarting gedit. The UI displayed me an error message about not being able to install the style but it still appeared in the list and seems to work just fine.