Useful Geany plugins, tips and tricks

Updated: February 6, 2020

A few months ago, in my quest to find THE text editor for Linux, I came across Geany, and it got me pleasantly surprised. It shares a lot of underlying goodness with Notepad++, my go-to text program, a Windows-only application that I nevertheless often use in various distros through WINE. Geany is powerful, efficient and versatile, and so I expanded my exploration quite some.

I also got lots of emails from you, telling me about useful plugins, which I could try to improve my productivity still further, especially since I've noted Geany doesn't have all the features that its Windows counterpart boasts. Well, in this article, I'd like to share with you some of the excellent plugins as well as some other neat tricks in Geany, all of which ought to make it even more practical and fun. Let's commence.

Teaser

Auto-close

With this plugin, you can auto-complete or auto-close brackets. Quite handy for when you're writing code, and it should help you avoid the situation where you end up with incomplete blocks. I tried this, and it works fine, including HTML elements like div or p. You do need to start the close sequence, but otherwise, the matching is pretty accurate.

Auto-close plugin

Auto-close settings

Auto-close works

Save Actions

One of the comments I had in my review was - with Notepad++, you can leave unsaved files in the editor, and they will be automatically recovered after you close the program and launch it again. So files like New2* or whatnot will actually still be there. Not so with Geany.

Well, you can work around this with the Save Actions plugin. It's not too intuitive, but it does the job. There are several sub-functions available - auto save, instant save and backup. The first one allows you to save content whenever you "lose" focus, i.e. switch to a different program or tab, or automatically with a pre-defined time period. The Instant Save option will save any file you work right away, which is kind of similar to what Notepad+ does, however it does explicitly ask you for a filename. The last option lets you keep backups of your work documents, but it doesn't seem to automatically rinse them away, so you can end up with a bit of clutter. However, it works reasonably well, although it can be somewhat refined.

Save Actions

Save Actions settings

Export

This is a rather useful plugin. Enable it. You then get two options - HTML and LaTeX. I converted my sample C file, and the output looked fine. But then, the real test is to actually show these files in proper applications (browser and PDF viewer), to see what actually gives. Now, this turned out to be more difficult than I expected.

Export plugin

Exported LaTeX code

HTML wise, when I clicked the Run & View button, Geany displayed the file in Chrome, even though Firefox is my default browser. I had to change the browser configuration from "sensible browser" to Firefox, and after that, the HTML file association was all right.

HTML in Firefox

With PDF files, Geany complained that it couldn't find Evince - which is understandable, given that I'm running KDE in this particular test instance, so Okular is the viewer de jour. Alas, changing this default association was impossible.

/tmp/geany_run_script_0BEU4Z.sh: 7: /tmp/geany_run_script_0BEU4Z.sh: evince: not found

Reading the online Geany documentation, the trick is supposedly to change the .gtkrc-2.0 configuration file in one's user directory - simply replace the PDF viewer string to whatever's installed on the system. I did try this, and it still didn't work.

gtk-print-preview-command = "okular %f"

I then tried to edit the Geany configuration file under ~/.config/geany/geany.conf, and it pretty much reflects what you see in the UI. There's no line referencing a PDF viewer, and adding the line above does nothing. So the solution to actually get Geany to show PDF files was to either symlink okular to evince or install this program. I tried both - and in both cases, the PDF file didn't really exist and couldn't be shown.

At this point, I realized that Geany doesn't seem to distill tex files into PDF - maybe I needed to run the Build command, but I haven't tried that yet, so I installed the texlive package and used the pdflatex command to generate the PDF.

pdflatex file.tex

And it worked fine. The output is excellent - including the color coding that matches the original C file.

PDF in Okular

Now, a side note, you may think you want to use pdftex to convert the files, but this won't work, because Geany generates LaTeX and not TeX, and if you try this venue, you will hit a seemingly silly conversion error:

pdftex test.c.tex
This is pdfTeX, Version 3.14159265-2.6-1.40.18 (TeX Live 2017/Debian) (preloaded format=pdftex)
restricted \write18 enabled.
entering extended mode
(./test.c.tex
! Undefined control sequence.
l.2 \documentclass
[a4paper]{article}

LaTeX wizard

You can also generate LaTeX files, and Geany comes with useful pre-build commands. Quite handy. Sure, you do need to know what you're doing, but this can actually help save you the need of installing a complete suite to handle LaTeX, like perhaps LyX or TeXstudio. Quite handy. Speaking of nerd stuffs, maybe you are also interested in my guide on how to make your files pretty, with some rather handy LaTeX & Lyx tips and tricks. There you go.

LaTeX wizard

Scribble & Tasks

In the bottom pane, you get a whole bunch of useful messages, including compilation log, file log and such. But then, you may not have noticed and tried the Scribble pad or the Tasks tab. The former lets you jot down notes and ideas and comments for your working project. The latter is useful in that it will show all TODO and FIXME lines in your files. The caveat is that I only managed to do this for code files, e.g. with .c extension, but not ordinary text files (txt). I also couldn't find where to override the tasks keywords.

Scribble

Todo list

Code linting

We've seen this in my original review - one of the many options available to entrepreneuring coders. But then, if you do run this command, and you don't have the right linter installed, you will see an error. In this particular case, the cppcheck package was missing. Geany won't auto-install dependencies for you, so you need to sort those out manually.

Cppcheck failed

sudo apt-get install cppcheck

Successful lint

Conclusion

I am warming up to Geany. This is a handy little application, with tons of hidden layers of goodness. I still think it's not quite as versatile as Notepad++, and the latter has way more useful plugins, but even so, Geany is a great program, and well ahead of other Linux text editors. We only touched on some of the fine stuff here.

The integration with the ecosystem can be better, e.g. tweaks, configuration, default programs, and helper tools, and additional plugins (or an online repo of such) would give Geany even more power and flexibility with advanced users. That's something to consider and test in the future. As always, if you have magic tricks up your sleeve, and you'd like to share them, bring them on. I will gladly explore additional facets of productivity and fun that Geany has to offer. Take care.

Cheers.

You may also like: