
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:
use_tab_to_indentfromtruetofalsecomplete_snippets_whilst_editingfromfalsetotruescroll_stop_at_last_linefromfalsetotrue
Tips and handy key combinations
Use the search field in the toolbar. This provides incremental search forward. For easier access, change the key combos dealing with it as detailed below.
Shift-Ctrl-{Delete,Backspace} to delete from the current position to the {End,Beginning} of the line.
Use the Alt-key combos as much as possible when dealing with the GUI -- especially dialogs. Also for menu items that you haven't assigned a key combo to.
- In the Open and Save File dialogs, Alt-{Up,Down} moves you up and down directories.
For navigating between locations in a single file, make use of the bookmarking feature (Ctrl-M to toggle, Ctrl-. and Ctrl-, to hop forward and back).
For navigating between locations across multiple files, you might try out the forward-location and backward-location commands (I set them to Ctrl-> and Ctrl-< below). This feature might be more helpful if there were a gui tool for viewing, editing, an navigating this "location list"...
Right-click on any editor window tab to choose see them all listed in "tab-order".
There's no "open new line here" command. Instead, put the cursor on a blank line and hit Ctrl-D.
Alt-1 and Alt-0 switch you to the first (far left) and last (far right) tab, respectively. Shift-Ctrl-{PgUp,PgDn} does the same.
Scrolling the mouse over the file tabs causes Geany to switch tabs.
Modified key combinations
Geany key combinations generally follow a few conventions as described
in the HACKING file. Some of them are:
Pairs of commonly-used complimentary commands often have 2 totally different key combos: one to do the action, another to do the opposite.
Most features are activated by Ctrl-key, with Shift-Ctrl-key doing some extended or augmented version of Ctrl-key. In one instance though (Shift-Ctrl-G), Shift'ing does the opposite.
Alt-key combos are reserved for dealing with menu items.
Other special key modifiers are Ctrl-Alt, and also possibly Shift-Alt.
I like to follow some additional conventions:
- Shift-Alt keys are used for selecting text, or else for accessing GUI elements.
- Ctrl-Alt keys are used sparingly for advanced or else lesser-used features.
- I like using punctuation characters in key combos, where appropriate.
So, I make the following changes to the default Geany key bindings.
Changes
First, remove these:
- Ctrl-T (transpose current line) -- I never have a need for this one.
- Shift-Ctrl-R (reload symbol list) -- Same.
- Ctrl-E (toggle commentation) -- Using this key for something else.
- Shift-Alt-D (insert date) -- Seldom-used. Doesn't follow my preferred convention. Can access via menu item.
Then change these:
- Change Find from Ctrl-F to Ctrl-Alt-F.
- Change "Switch to Search Bar" from F7 to Ctrl-F (incremental search is way more common than needing that big search dialog).
- Change "back to editor window" from F2 to Ctrl-E ('E' for Editor).
- Change toggle commentation from Ctrl-E to Ctrl-#.
- Change indent/unindent from Ctrl-{I,U} to Ctrl-) and Ctrl-(.
Using the Alt keys for GUI manipulation:
- Change scroll-to-current-line from Shift-Ctrl-L to Shift-Alt-V.
and finally, add these:
- Ctrl-{0,9} for indent/unindent by-space.
- Ctrl-@ for go to tag definition.
- Ctrl-< and Ctrl-> for navigate back and forward a location.
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
- A way to do incremental search backward. What could work fine would be a key combination to get me to the Search field in the Toolbar in a search-backward mode. Leaving the Search field would revert the search mode to regular search-forward. A nice key combo to use for this is Ctrl-R.