How do I adjust the margin for the line numbers in gEdit?

The request for more space between line numbers and content has sometimes been voiced on the mailing-lists before, and here is a summary of my investigation of the current situation.


We can find any additional gedit settings by entering in terminal

gsettings list-recursively | grep -i gedit

and then we can narrow it down a bit further by entering

gsettings list-recursively | grep -i gedit | grep -i margin

which returns the margin entries and your current settings:

org.gnome.gedit.preferences.editor display-right-margin true
org.gnome.gedit.preferences.editor right-margin-position uint32 2

But these are right margin settings, and are just the same as the gui settings menu; there also doesn't seem to be any appropriate possibilities in the rest of the settings or any plugins that would be useful for you.

It is important to note that gedit uses gtksourceview, and, when examined, the feature set from that library will be familiar to gedit users. There is, however, no mention in the specifications of the left margin or a way to specify a separation between line numbers and the entries in your gedit document.

However, I think you could do what you want by patching the gtksourceview library, and patching gedit. After looking at the gtksourceview specifications I think you would need to patch the gtksourcegutter settings; in the documentation it is noted that

The GtkSourceGutter object represents the left and right gutters of the text view. It is used by GtkSourceView to draw the line numbers and category marks that might be present on a line. By packing additional GtkSourceGutterRenderer objects in the gutter, you can extend the gutter with your own custom drawings.

There is a discussion on the gutter in the mailing-lists, although not with specific reference to your question, but with regard to possible customisations.


You may have thought you had enabled space between line numbers and entries in your document by carrying out the process shown in the screenshot below.

You create a new file with gedit, go to edit > preferences > view and enable the right margin and set it to 2, for example. Then you place the cursor on the margin, type something, press return, and then save the file. Then when the file is reloaded the space between the numbers and the content stays until you go beyond the margin.

This has happened to me a few times, and is confusing, but is not a reliable way of doing what you want. As there are no official settings available the only way to do what you want would be to patch gtksourceview and gedit.

enter image description here