Geany

Author: John M. Gabriele | back to index

---

About Geany

Geany is a nice little GTK-based editor/IDE that's being actively developed. Here's a few tips for getting the most out of it.

Installation

I like to build Geany right from the code in the Subversion repository, rather than use the version supplied by my GNU/Linux distribution. Geany HEAD is pretty stable, and it's nice to get all the improvements right when they're committed (rather than waiting for the next release).

Rather than install to /usr/local, I prefer to use my own ~/opt tree. For this to work, your PATH environment variable should have /home/<you>/opt/bin in it. To set PATH, I have the following line at the end of my ~/.bashrc file:

PATH=/home/john/opt/bin:$PATH

If you make that change (with s/john/<you>/), and log out & log back in, you should then see that ~/opt/bin directory at the front of your path. Check it like so:

echo $PATH

Now, the system should find geany just fine. Try:

which geany

and it should say: /home/<you>/opt/bin/geany.

If you're building and installing your own Geany, you probably don't want to have 2 Geanys installed. Check if you've installed the one provided by your distro. For example, for Debian (or a Debian-based one like Ubuntu):

dpkg -l | grep geany

If it's there, you can remove it like so:

sudo aptitude purge geany

Build and install

To build and install to your own ~/opt, you'll just do the usual steps:

./configure --prefix=/home/<you>/opt
make
make install

When first getting the source (and also after certain updates), you'll need to run ./autogen.sh first, as described on the Geany site.

Note, autogen.sh will also automatically do a configure for you as well. If you want to pass options to configure, you can give them to autogen.sh and it will pass those on for you. For example:

./autogen.sh --prefix=/home/john/opt --disable-vte --enable-the-force

Configuration

In ~/.geany/geany.conf, I change the following hidden preferences:

Tips and handy key combinations

Modified key combinations

Geany key combinations generally follow a few conventions as described in the HACKING file. Some of them are:

I like to follow some additional conventions:

So, I make the following changes to the default Geany key bindings.

Changes

First, remove these:

Then change these:

Using the Alt keys for GUI manipulation:

and finally, add these:

Piping to custom commands

You can pipe the contents of the current selection to an external shell command, replacing the selection with the output of said command: Edit --> Format --> Send Selection to --> Set Custom Commands. A very handy one (often used with Shift-Alt-P) is fmt -w72 (mapped to Ctrl-1).

Syntax highlighting

I wrote a Perl script to help set up nice syntax highlighting colors. It's called set_geany_colors. There are currently only a handful of colorschemes available, but users may want to submit their own for inclusion in the distribution.

Plug-ins

You can write you own plug-ins for Geany in C, or else you can install Jeff Pohlmeyer's GeanyLua and write them in Lua. Here's some quick instructions for installing GeanyLua.

To build GeanyLua from source, you'll need to have Lua installed on your system. On Ubuntu 7.10, install like so:

sudo aptitude install liblua5.1-0-dev

Then, build GeanyLua from source as per the instructions:

./configure
make
make install

If you have Geany installed in a non-standard location, run that configure step like so:

PKG_CONFIG_PATH=/home/john/opt/lib/pkgconfig ./configure

Note, you need to already have the ~/.geany/plugins directory present or else the plugin won't be installed correctly. The installation procedure seems to really only consist of copying files to your ~/.geany directory.

Quit Geany and restart, and then go to Tools --> Plugin Manager and enable GeanyLua. You'll now have a Tools --> Lua Scripts menu item available.

For more information, see the html docs that come with GeanyLua. Key bindings for your Lua scripts is currently under development.

Key bindings

Geany provides a way for assigning key bindings to plug-ins, and it's integrated into how Geany normally sets key bindings. It's up to the plug-in to make use of this functionality.

However, if you've got a lot of GeanyLua plug-in scripts that you want to use regularly, it could become a pain in the neck finding good bindings for all of them (since Geany itself takes up many already), not to mention remembering them all.

Note: GeanyLua still actually provides a legacy and deprecated way outside of Geany to provide key bindings for your Lua scripts, but it's something that's manually done inside your scripts. See the GeanyLua docs for more details.

One solution is to have just one key binding for one GeanyLua plug-in script, and then have that script delegate to the rest of the Lua plug-ins depending on which key you hit next. For this, Jeff has provided us with a keygrab function. The idea is, you write one main script that looks something like this:

--[[
Assign sub-keys for any Lua scripts you want to
quickly access via the keyboard.
--]]

key = geany.keygrab()

if key == "r" then
    dofile("/home/john/.geany/plugins/geanylua/examples/edit/reverse.lua")
elseif key == "p" then
    dofile("/home/john/.geany/plugins/geanylua/examples/edit/proper-case.lua")
end

and then assign a Geany key binding to that script (possibly Ctrl-!). You might name that script something like "01.forward-command.lua", and then drop it into your ~/.geany/plugins/geanylua directory.

Wishlist