Author: Dennis L. Ericson
Geany is a lightweight text editor for Linux based on the GTK2 toolkit. Geany supports internal and external plugins, and it excels as a source code editor, since it includes basic integrated development environment (IDE) functionality. Here’s an introduction to using Geany’s built-in features, including the IDE and built-in development capabilities.
Geany requires only the GTK2 (>= 2.6.0) runtime libraries (including Pango, Glib, and ATK libraries), and is not dependent on any X window manager or desktop environment. For reference, my system is a standard Dell laptop running Absolute Linux 12.1, which comes loaded with all the tools needed (as do most Linux distributions). You will also need a C/C++ compiler and the make utility.
Most Linux distributions have a binary package for Geany, but most are not up-to-date with the current 0.14 release, which is available in a gzip-compressed source code tar file. If you want the latest, you must download and build it. Geany uses the normal Linux configure, make, make install (as root) installation process. Perform the following steps in a console shell after downloading the tar.bz file to your home directory.
cd ~ tar -zxvf geany-0.14.tar.gz cd ./geany-0.14 ./configure make sudo make install
If all went well, you should be able to run Geany 0.14 by typing geany & on a command line.
The default setup for Geany displays three panes: the main code window, a sidebar on the left, and a message area on the bottom. The sidebar contains one tab for symbol definitions within the current file, and another for documents you currently have open. The message area contains five tabs, for Geany status messages, compiler execution messages, general Geany messages, a Scribble tab for note-taking, and a terminal for executing shell commands within Geany. Figure 1 shows the layout, along with the main Preferences screen (under the Edit pull-down menu), which allows a multitude of configurable features; you can see its tab headings on the left side of the window.
Geany supports everything developers need to edit source code, including cut and paste, search (including limited expressions), replace, indentation, code folding, syntax highlighting (for more than 30 common languages), line wrapping, filetype (CR/LF), white space and tab conversion, column mode, symbol list support, drag and drop editing, standard CTRL-z undo, and a host of other editing features.
Geany as IDE
To highlight Geany’s IDE features, let’s try a (trivial) development code change to the source code from Geany itself, after which we’ll compile and install it.
First we need to configure our build setup for the Geany source code. Under the drop-down menu Build -> Set Includes and Arguments, edit the Build line to say make (Figure 2). Using Geany, edit line 174 of /src/about.c, and replace (“A fast and lightweight IDE”) with (“A SUPER fast and lightweight IDE”). Press F9, or from the menu click on Build -> Build (no need to save first). The Compiler tab of the bottom message window will show the results of the compile request.
Then, under Terminal in the bottom message window area, su or sudo to root, cd ~/geany-0.14/src, and type make install. After exiting and reloading Geany, go to Help -> About, and you should see the change you made: ‘A SUPER fast and lightweight IDE.’
Let’s go back and look at the symbol list in the sidebar window for the file about.c, which includes functions, macros, and variables, listed alphabetically with the line number in parenthesis. Clicking on any of these will bring you to that line automatically. If you want to see the list arranged in order in the file, click Document -> Fold All.
Related to the symbol list, let’s look at tags, which allow you to find definitions of functions, macros, and variables. Geany has built-in tag generation and tag support, although it’s not compatible with other tag standards such as Exuberant Ctags. Tag generation took me some time to figure out, as it appears to need full path specifications as well as a specific tag filename format, but I was able to get it to operate correctly by running the following command from the /src/ directory:
geany -g geany014.c.tags ~/geany-0.14/src/*.c ~/geany-0.14/src/*.h
This generates a Geany tag file for .c and .h files; note the ‘.c.tags’ format of the tag file. Loading the tag file was easy, using the drop-down item from the Tools menu. The biggest disappointment for tags though is that Geany supports tag definition jumping (click on the tag, then right-click to pull up a menu) only with files that are open; if a file is not open, Geany does not open the new file and jump to the tag definition. However, autocomplete works fine, displaying a menu of possible completions from the global tags file as you type each letter (four letters or more).
Geany also has limited support for projects under the Project menu. Creating a project defines the base directory for builds, and provides a convenient way to access files — that is, each time you open a project, the files you had open before are opened again. In addition, the build tools (Make and Run) change based on project, so if you were writing C code in one project and Perl in another, you could have and maintain separate build parameters. And although not configured as default, a built-in plugin manager (Tools -> Plugin Manager) is provided to list the project files on the sidebar window, a typical feature found on most IDEs.
In addition to the file browser plugin, Geany is shipped with several other plugins that are not enabled by default: Auto save (automatically saves all open files), Classbuilder (creates source files for new class types), Export (exports the current file into different formats), HTML Characters (inserts HTML character entities), and Version Diff (creates a patch of a file against a version control system; currently Subversion, CVS, and Git are supported). In addition there are many more external plugins available for downloading, including spell checking (via aspell), backup with each save, and SendMail support. These external plugins exist as source code and have to be downloaded and compiled to be used.
Geany also offers templates that allow developers to insert prepared text where desired in the code. All can be configured, although some require changes to Geany text files (see ~/.geany/templates/). Templates are available for ChangeLog Entry, File Header, Functional Description, and BSD/GPL notices. Templates can also be set up for an entire filetype, so each new file always contains all necessary boilerplate information.
New since Geany 0.13 is printing via GTK. Previously Geany printed only via an external command, which made printing with a remote printer on CUPS difficult. With GTK print support, printing on any CUPS printer is as easy as with any other application, with the selection of available printers popping up in a window when the print command is requested. You can even print multiple pages on one sheet, something I have done often when printing large source listings. If you are using an older version of Geany, updating to 0.14 is worth it just to get better printer support.
But all is not rosy, as there are some common IDE features that are missing in Geany. Although there is supposed to be a plugin available for debugging using the GNU Debugger, I was unable to find and download it using the link provided, so I cannot say whether Geany supports source-level debugging. Geany also does not provide a way to see differences between versions of a file, although there is some plugin support for this when you’re using a version control system. And although Geany supports C++ and other object-oriented languages, it does not provide any object-oriented tools, such as a class browser or class hierarchy diagram.
In summary, although it lacks a few features found in full-fledged IDEs, Geany is a wonderful, fast, and useful source code editor, supporting most of the functionality needed by developers. I am a little disappointed that tags don’t work when the applicable file is not open, and there is no file difference tool included. On the positive side, the build tools work well, and autocomplete is a great time-saver, as it helps reduce function/variable misspellings. The triple window interface is conveniently laid out, and Geany supports everything regarding source code editing that you could need.
- Tools & Utilities
- Desktop Software