10 Tweaks to Supercharge Gedit as Code Editor

GNOME may have ditched Gedit as the default text editor but it is still a favorite of long-time Linux users.

It is primarily a text editor, but with some tweaks, it can work as a lightweight code editor.

Yeah! Why use VS Code or other dedicated code editors for writing Bash scripts or simple programs in other languages? Gedit saves the day.

I’ll share some of my favorite Gedit tips and tricks in this article. While most of the tweaks are beneficial for writing codes, some could be helpful for general text writing as well.

1. Install plugins

Few people don’t even know that Gedit has a robust plugin feature. You can install plugins to get additional features.

There are two kinds of plugins:

  • Official Gedit plugins that are accessible from the editor menu
  • Third-party plugins that can be downloaded from the project websites and placed into the plugins directory (discussed below)

The Gedit plugins can be located in /usr/share/gedit/plugins or ย ~/.local/share/gedit/plugins directories.

10 Tweaks to Supercharge Gedit as Code Editor
A manually installed plugin in the local > share > gedit > plugins directory

You can access the available and installed plugins by clicking the Hamburger menu and then opening the Preference window,

10 Tweaks to Supercharge Gedit as Code Editor
Preferences

The Preferences window has the Plugins tab and you can see all the plugins available to you. You can use the checkbox to enable and disable the plugins.

10 Tweaks to Supercharge Gedit as Code Editor
Plugins menu inside Preferences

2. Show file browser in the side panel

If you are working on a project that has multiple files and folders, getting the file browser to see all the available files in the sidebar is quite helpful.

Go to Preferences -> Plugins and enable the File Browser Panel.

10 Tweaks to Supercharge Gedit as Code Editor
File Browser Panel Plugin

After that, click on the hamburger menu at top right and enable the Side Panel View from Menu View -> Side Panel

Now change the side panel view to file browser, if not already.

10 Tweaks to Supercharge Gedit as Code Editor
Change the side pane to show File Browser

3. Embed a terminal

Yes! You can embed a terminal right into the Gedit text editor.

What’s the point? Well, if you are writing programs or scripts, an embed terminal helps you run the script and check the code changes right there in the editor.

10 Tweaks to Supercharge Gedit as Code Editor
Embedded Terminal in Gedit

To get this, first install the plugin (for Ubuntu):

sudo apt install gedit-plugin-terminal

Once the plugin is installed, enable it from Preferences->Plugin.

10 Tweaks to Supercharge Gedit as Code Editor
Embedded terminal Plugin

Mow, enable bottom panel from hamburger menu -> View -> Bottom Panel

10 Tweaks to Supercharge Gedit as Code Editor
Enable the Botto Panel View

4. Markdown preview

Love Markdown? Me too!

There are several Markdown editors available for Linux but you don’t have to install another application just to use Markdown.

With the help of a plugin, unsurprisingly called Gedit Markdown Preview, Gedit is perfectly capable of rendering Markdown code.

Arch users can find it in the AUR as gedit-plugin-markdown_preview package.

Other Linux users can find the installation instructions on the project webpage.

Once it is installed, enable it in plugins. You must enable the side panel view from the hamburger menu –> View > Side panel

10 Tweaks to Supercharge Gedit as Code Editor
Enable Side Panel

With that, it starts showing rendered text for Markdown text in the side or bottom pane.

10 Tweaks to Supercharge Gedit as Code Editor
Markdown Preview in Gedit

5. Create snippets

Good coders code. Better coders reuse.

If you find yourself reusing same piece of code or text, you can save it as snippet and insert it when needed. This will save you some time (and frustration).

Enable the Snippet plugin first.

10 Tweaks to Supercharge Gedit as Code Editor
Enable Snippet Plugin

Now you can access the snippets from Hamburger Menu -> Manage Snippets

10 Tweaks to Supercharge Gedit as Code Editor
Manage Snippet Option

You’ll find that it already has several snippets added for various programming languages.

10 Tweaks to Supercharge Gedit as Code Editor
A pre-created CPP Main snippet.

You can also add your snippets in the desired folder by clicking the + sign on the bottom left. You may also assign a shortcut key to snippets to insert them even more quickly.

10 Tweaks to Supercharge Gedit as Code Editor
A manually created snippet for Markdown Table.

For example, I added a new snippet for adding a Markdown table and assigned a keyboard shortcut and tab trigger to it (as seen in the above image). Now, if I press CTRL + Alt + S in a Markdown document, a table is added. Alternatively, typing table and pressing the TAB key also adds the Markdown table.

๐Ÿ’ก
Usually, the snippets are saved in /usr/share/gedit/plugins/snippet folder as XM docs, but I could not find where the newly added snippets are saved.

6. Fix the dark mode problem

Coders love dark mode. Gedit adheres to the system theme, and if you switch to dark mode at the OS level, it also switches to dark mode.

The one major problem is that you cannot read anything on the currently selected line because both text and line highlights are white colored.

10 Tweaks to Supercharge Gedit as Code Editor
Text not visible because of line highlight

There is no fix for this. However, a workaround is to either disable highlighting the current line or use a different color scheme.I prefer choosing a different color scheme.

Go to Preferences -> Font & Colors and then select a dark color scheme like Oblivion. It will change the color scheme a little but at least you will be able to see the text on the highlighted lines.

10 Tweaks to Supercharge Gedit as Code Editor
Colour scheme is changed to make the text visible under highlight line

7. Quick highlight selected text

Double-click a word and Gedit highlights all the occurrences of the same word in the entire document.

10 Tweaks to Supercharge Gedit as Code Editor
Words are automatically highlighted when one instance is selected

This feature is not enabled by default though an official plugin is available.

Go to Preferences -> Plugins and enable the Quick Highlight option.

10 Tweaks to Supercharge Gedit as Code Editor
Quick highlight default plugin in Preferences > Plugins

8. Show line numbers

Many code editors show the line numbers by default. It helps you quickly go to the line when you see a ‘syntax error at line X’.

You can enable line numbers by going to Preferences -> View -> Display Line Numbers:

10 Tweaks to Supercharge Gedit as Code Editor
Enable Line numbers in Gedit

You may also enable or disable it from the bottom.

10 Tweaks to Supercharge Gedit as Code Editor
Enable Line Numbers from the bottom options

9. Save a version

If you are modifying a file, perhaps it would be better to create a backup copy? Gedit can do this automatically.

Enable this feature in preferences -> Editor -> Create a Backup copy.

10 Tweaks to Supercharge Gedit as Code Editor
Create Backup copy before saving setting in Preferences

A file with the name of the original file appended with a ~ symbol will appear as the backup file.

10 Tweaks to Supercharge Gedit as Code Editor
Backup File in File Manager

10. Autosave files

Since we are talking about versions and backups, how about enabling autosave in Gedit? This way, if you are working on a document and forgot to save it using Ctrl+S manually, the changes get saved automatically.

๐Ÿšง
This feature does NOT work on a completely new document that has never been saved on the disk.

From Preferences -> Editor, you can enable the Autosave feature. By default, it autosaves every 10 minutes but you can change the duration to your liking.

10 Tweaks to Supercharge Gedit as Code Editor
Autosave after every specified time limit (default)

There is also a third-party smart-auto-save extension that autosaves the document as soon as you stop typing it.

10 Tweaks to Supercharge Gedit as Code Editor
Smart autosave plugin, that saves the document once typing is stoppedย 

Know more Gedit tricks?

One of the joys of using any piece of software is discovering it’s not-so-obvious features.

We have covered such application-specific tweaks in the past. Take a look at Nautilus tips:

13 Ways to Tweak Nautilus File Manager in Linux to Get More Out of it
Nautilus is GNOMEโ€™s default file manager application, and you may have seen it in many Linux distributions. Itโ€™s a good file manager with plenty of features. However, you can enhance your experience by employing some tweaks and tips. I am going to share such tips and tweaks in
10 Tweaks to Supercharge Gedit as Code Editor

Or, the Flatpak tips and tweaks:

6 Tips and Tools to Enhance Your Flatpak Experience in Linux
If you love using Flatpak applications, here are a few tips, tools, and tweaks to make your Flatpak experience better and smoother.
10 Tweaks to Supercharge Gedit as Code Editor

Which Gedit tweaks you liked the most here? Do you know a killer Gedit feature that not many people are aware of? Share it with us in the comments?

Leave a Comment