how to show line numbers in gedit text editor

There are many graphical editors in Linux, many with specific or unique features for text editing. GEdit and Kate are probably the most popular of these, mostly because they are tied to desktop environments such as Gnome and KDE respectively. There are several more that you could try such as Cream, JEdit, Kwrite and Scribes.

GEdit has been quite popular because of its simplicity and also because it is installed by default on most distros. Also, you could run gedit editor on most distros and most graphical desktop environments if you install it (and its libraries) separately.

By default, gedit does not display the line numbers when showing a file or when you create a new document. You can change this in the Preferences such that the line numbers are always displayed.

gedit preferences in linux

Firstly, you need to open the Preferences panel in GEdit to do it.

  1. Pull down the hamburger menu
  2. Select Preferences option in the drop down menu
  3. Click on the View tab in the Preferences panel
  4. Select the option Display Line Numbers
  5. Close the Preferences panel

As you can see, there are other line related options that you can customize in that tab as well.

Display Right Margin at Column: This displays a vertical line at predefined location denoting the right margin. This can be useful while you are editing a file and want to keep the content to less than a certain number of characters.

Enable Text Wrapping: You can specify that the text needs to be wrapped to the next line. This allows long lines to be broken into the next line for display purposes, making it easier to read. You do not have to scroll horizontally to view long lines.

Do not Split Words Over Two Lines: This prevents the words from being split while wrapping long lines of text

I am yet to come across a (decent) text editor that does not have the ability to display line numbers. Some of them may not be enabled by default. No matter which text editor you are using you should be able to find an option in the preferences that will enable the display of line numbers. You will just have to dig around a bit…