Using Geany as a replacement for UltraEdit

UltraEdit for Linux is extremely buggy and corrupts the text documents. The corruption happens with using column mode, possibly worsened by using split windows (I mostly use vertically split). Column mode has always been buggy in UltraEdit, but in the Linux version it is extreme.

Also, it doesn’t like emojis at all (coming from, say, copy-pasting from a Twitter profile) and will simply delete all text (or corrupt text, crash, or freeze) if an emoji character is deleted… (there is no way in UltraEdit for Linux to remove emoji characters without also losing content).

UltraEdit for Linux also lacks behind the Windows version (as of early 2020 at version 18, 2018). Note that I am a veteran user of UltraEdit (since 1998), and it works fine on Windows (except for occasional problems with column mode).

UltraEdit for Linux version 20 was released 2020-06-26. I haven’t had a chance yet to review it, in particular if the bugs have been fixed.

An alternative is Geany, and it is similar to Notepad++ on Windows. But Geany is not nearly as clunky as Notepad++.

This blog post is intended to be step-by-step instructions for quickly getting up and running with Geany on a new system, in particular such that it works similar to UltraEdit (especially the keyboard shortcuts). It also covers missing features in Geany. Though the focus is on Linux, the instructions also cover Windows.


Ubuntu/Debian, from the terminal

sudo apt-get update
sudo apt install geany

For Windows, use the EXE installer. Note that in order to use the English version of Geany on a non-English version of Windows, the environment variable “LANG” must be set to “en”. As this may affect other things, the easiest is to make a BAT file that sets the environment variable and launches Geany (so the change is only for Geany).

Some basic plugins

To get a menu item for copying the full path of the current document to the clipboard, install the plugin with the overly generic (meaningless) name “Addons”. The following is for Ubuntu/Debian from the command line.

First list the available plugins:

lsb_release -a # List Ubuntu version
apt-cache search geany

Note that some plugins are not available in later versions of Ubuntu. For example, the Geany plugin “Debugger” is available in Ubuntu Ubuntu 16.04 (Xenial Xerus), but not in Ubuntu 19.10 (Eoan Ermine) (on Ubuntu 16.04, the output includes “geany-plugin-debugger – debugger plugin for Geany”).

It should include:

geany-plugin-addons - miscellaneous plugins for Geany

Install “Addons”, using the exact name from above:

sudo apt install geany-plugin-addons

Enable the plugin “Addons” in the Plugin Manager, menu Tools → Plugin Manager. After this, there is a new menu command, menu ToolsCopy File Path. Note that it is available immediately; there isn’t any need to restart Geany.

For Windows, use the EXE plugin installer. It will install a number of plugins, including “Addons”.

Change theme, e.g., to a dark mode one

Similar to UltraEdit, it is possible to use dark mode. It is, however, not enabled by default in older versions of Geany – extra files must be added to the installation (it is enabled with Geany 1.37.1 on Windows).

Download a set of themes from GitHub, uncompress the ZIP file, and copy the content of folder “colorschemes” to folder ~/.config/geany/colorschemes (about 35 files). On Windows, copy to folder %ProgramFiles(x86)%/geany/colorschemes (e.g., C:\Program Files (x86)\Geany\data\colorschemes).

Change the theme: menu ViewChange Colour Scheme… → choose “Delt Dark” → press “Close”.

Alternative dark themes are: “Himbeere”, “InkPot”, “Kugel”, “Relesk’s MC” (darkblue background), “Monokai”, “Oblivion 2”, “Railcasts 2”, “Retro” (green text), “Sleepy Pastel”, “Solarized (dark)”, “Spyder Dark”, “Steampunk”, “Tango”, “Tinge”, “Vibrant”, and “Zenburn”.

“Vibrant” is probably the closest to the UltraEdit one.

Open .txt files with Geany by default

In Ubuntu, .txt files open in the extremely irritating “Text Editor” (why did they have to change how Ctrl + F works??).

Right click on some .txt file in a “Files” window (or Ctrl + I) and choose “Properties”. In tab “Open With” (the last one), find “Geany” in one of the three lists, select it and press “Set as default”. Close the dialog.

Turn off various non-text panels

Menu ViewShow Message Window, to not checked.
Menu ViewShow Toolbar, to not checked.
Menu ViewShow Sidebar, to not checked.

Set font size

Menu View → Change Font…, to 18. The font, “Monospace Regular”, is OK (“Monospace Normal” on Windows).

Note that there is a separate zoom level. It works in the same way as in a web browser (e.g., Ctrl + + to zoom in).

Turn off everything with TABs

No more TABs! They are evil.

Menu EditPreferencesEditor → tab IndentationType. Set to “Spaces”.

Menu EditPreferencesEditor → tab IndentationTab key indents. Check it.

Note 1: It works only for documents opened after this change (not current ones), so the easiest way is probably to restart Geany.

Note 2: It is not entirely clear what is up with setting “Tab key indents”. It seems to have no effect in some versions of Geany (perhaps its effective setting is automatically checked if “Type” = “Spaces”?). Its meaning may even have been inverted at some point… If it doesn’t work as intended, try both unchecking and checking this setting. It is safest to restart Geany after changing the setting.

Note 3: In some versions of Geany, this setting is remembered per document. To retrospectively change it, do menu command ProjectApply Default Indentation. This will not replace existing TABs, but any further actions with the TAB key will work as expected.

Number of files in the list of recently opened files

Menu EditPreferences → tab Files → section MiscellaneousRecent files list length. Change it from 10 to 50.

Changing keyboard shortcuts to the same as in UltraEdit

So they are the same as in UltraEdit. This is also important for using a macro keyboard (no need for duplication).

The keyboard shortcuts are changed in menu EditPreferences (which itself has keyboard shortcut Ctrl + Alt + P – but it conflicts with the Cinnamon applet “Color Picker”…) → Keybindings

Close document (Ctrl + F4)

E.g., so a macro keyboard works the same. Note: Ctrl + F4 appears as “<Primary>F4” in Geany.

If the window manager is Xfce (e.g., using MX Linux or Xubuntu), Ctrl + F4 is already used and trying to use it in Geany will not work. To make it work, first clear it by Win + “w” → “Window Manager” → tab “Keyboard” → select “Workspace 4” → press “Clear”“Close”. (Incidentally, this also makes Ctrl + F4 work in other applications, like Firefox.) Also clear the shortcut for “Workspace 2”, “Workspace 3”, and “Workspace 5” – as we are also going to use Ctrl + F2, Ctrl + F3, and Ctrl + F5.

Item “Close” in section “File”.

(Original keyboard shortcut: Ctrl + W)

Find next (F3)

E.g., so a macro keyboard works the same.

Item “Find Next” in section “Search” (about 40% way down).

(Original keyboard shortcut: Ctrl + G)

Find previous (Ctrl + F3)

E.g., so a macro keyboard works the same.

Item “Find Previous” in section “Search” (about 40% way down).

(Original keyboard shortcut: Shift + Ctrl + G)

Set bookmark (Ctrl + F2)

E.g., so a macro keyboard works the same.

Item “Toggle Marker” in section “Go to” (about half way down).

Note that the Ctrl key is listed as “Primary”.

(Original keyboard shortcut: Ctrl + M)

Next bookmark (F2)

E.g., so a macro keyboard works the same.

Item “Go to Next Marker” in section “Go to” (about half way down).

Note that the Ctrl key is listed as “Primary”.

Press “Override” to remove the existing keyboard shortcut for “Switch to Editor”.

(Original keyboard shortcut: Ctrl + .)

Previous bookmark (Alt + F2)

E.g., so a macro keyboard works the same.

Preparation: Ubuntu (and variants like Ubuntu MATE) may already use this keyboard shortcut.

In Ubuntu, disable the keyboard shortcut for “Key to execute a command” or “Show the run command prompt”. The way depends on the Ubuntu version. In older versions of Ubuntu, do it by by installing and using CompizConfig Settings Manager. It worked for me on Ubuntu 16.04 (Xenial Xerus).
In newer versions of Ubuntu, the CompizConfig Settings Manager method does not work. Instead, it is done without installing any software, in SettingsDevices (or just Keyboard) → Keyboard (left panel) → section System (2/3 down) → click “Show the run command prompt” → press the “Backspace” key to clear it → click Set. Its status should now be “Disabled” instead of “Alt + F2”. It worked for me on Ubuntu 18.04 (Bionic Beaver).
In even newer versions of Ubuntu, in SettingsKeyboard (left panel) → section Keyboard ShortcutsView and Customize ShortcutsSystem → click “Show the run command prompt” → press the “Backspace” key to clear it → click Set. Its status should now be “Disabled” instead of “Alt + F2”. It worked for me on Ubuntu 18.04 (Bionic Beaver).

In Ubuntu MATE (much easier): Window key → “k” → select “Keyboard Shortcuts”. In section “Desktop” (second section), double click “Show the panel’s ‘Run Application’ dialog box” and press backspace (to clear it). It takes effect immediately; there is no need to restart anything.

In Cinnamon: Window key → “sys” → select “System Settings”. In section “Hardware” (third section), open “Keyboard”. In tab “Shortcuts”, click “General” (left panel) → click on “Run dialog” on the right → select and single click on “Alt + F2” (will display “Pick an accelerator”) in the lower half (“Keyboard bindings”) → press Backspace (to delete/clear the shortcut). It takes effect immediately; there is no need to restart anything.

In Xfce (e.g., using MX Linux): Win + “k” → “Keyboard” → tab “Application Shortcuts” → select “xfce4-appfinder –collapsed” → press “Remove”“Close”.

In Lubuntu (LXQt/LXDE), edit file ~/.config/openbox/lubuntu-rc.xml near “A-F2”. For example, change “A-F2” to “A-F22” and add an XML comment as to why and document the original value (so it can more easily be reverted). It was tested with Lubuntu 18.04.

In Geany’s preferences, Keybindings, set Alt + F2 for item “Go to Previous Marker” in section “Go to” (about half way down).

(Original keyboard shortcut: Ctrl + ,)

Insert date (Alt + 2)

User defined as text template “2” in UltraEdit.

Example: 2020-03-29

But unfortunately it is not possible to set this keyboard shortcut. It conflicts with selecting a tab (the second tab in this case) and using combinations of Ctrl, Shift and Alt conflicts with the Geany plugin “Numbered Bookmarks”.

A workaround is to create a text template with the name “_2” and content “{command:date +”%Y-%m-%d”}”. Then the date is inserted by typing “_2” followed by TAB. Another workaround is to use Alt + 3 (which does work) and delete the time part, leaving only date part.

Insert date and time (Alt + 3)

Change keyboard shortcut:

In menu EditPreferencesKeybindings → sub section InsertInsert date: Change to Alt + 3 (from the default Shift + Alt + D)

User defined as text template “3” in UltraEdit.

Example: 2020-03-29T144457

Note that this overrides selecting the third tab with Alt + 3

(Original keyboard shortcut: Shift + Alt + D)

Go to line (Ctrl + G)

Item “Go to Line” in section “Go to” (about half way down).

Note that the Ctrl key is listed as “Primary”.

(Original keyboard shortcut: Ctrl + L)

Trim trailing spaces (Shift + F12)

Note: A keyboard shortcut was not added until version 1.34 (2018-12-16). Thus the default installed version of Geany on Ubuntu 16.04 (version 1.27, 2016-04-17) and Ubuntu 18.04 (version 1.32, 2017-11-19) does not have it… Ubuntu 19.10 has version 1.35, 2019-04-28. MX Linux 19.3 from November 2020 only has version 1.33 of Geany… Ubuntu 22.04 has version 1.38.

Item “Strip Trailing Spaces” in section “Document” (about 3/4 way down).

If it is not available, an alternative is to use the implicit Alt + D, S keyboard shortcut.

More keyboard shortcuts

Physical navigation of tabs

We want physical navigation of tabs with Ctrl + Tab (to the right) and Shift + Ctrl + Tab (to the left), like it is possible in Firefox (with unchecking of option “Ctrl+Tab cycles through tabs in recently used order”). Or in other words, we want the same keyboard shortcuts for this navigation in both Firefox and Geany, so we can easily use a macro keyboard (no need to use modifier keys for this very very common action).

There isn’t any setting for that in Geany, but there are actions for both kinds of navigation (with associated keyboard shortcuts):

Switch to left document
Switch to right document
Switch to last used document

In Geany’s preferences, Keybindings, section “Notebook tab” (near the end):

Clear the keyboard shortcut item “Switch to last used document” by double clicking and pressing OK – without pressing any keyboard shortcut (original keyboard shortcut: Ctrl + Tab).

Set “Switch to left document” to Shift + Ctrl + Tab (original keyboard shortcut: Ctrl + Page_Up).

Set “Switch to right document” to Ctrl + Tab (original keyboard shortcut: Ctrl + Page_Down).

(Note: Page_Up and Page_Down is the notation Geany uses, not e.g. Page Up or PgUp.)

Move tabs

We change the keyboard shortcuts for rearranging (document) tabs to be the same as in Firefox (so we can use the same keys on a macro keyboard).

In Geany’s preferences, Keybindings, section “Notebook tab” (near the end):

Set Shift + Ctrl + Page_Up for item “Move document left” (original keyboard shortcut: Alt + Page_Up).

Set Shift + Ctrl + Page_Down for item “Move document right” (original keyboard shortcut: Alt + Page_Down).

Text templates

In Geany, they are called “snippets” (templates mean something else in Geany).

Edit file snippets.conf, from menu ToolsConfiguration Filessnippets.conf. Add to the “[Default]” or “[None]” section.

Example – inserting a timestamp template for a video or podcast: _5=%cursor%ZZ min AA secs: BB\n\n

Output (entering “_5” followed by the TAB key): _ZZ min AA secs: BB. The cursor is set between the underscore and the “Z”.

And we can assign a keyboard shortcut, like in UltraEdit, in section “[Keybindings]” (but even then, Ctrl + 0 does not work – it could be a similar shortcut to the one in UltraEdit where we have used Alt + 0):

Insert date

Change the format of the template “Date”: Menu EditPreferences (Ctrl + Alt + P) → TemplatesDate, to “%Y-%m-%d”

Insert date and date/time

This is a built-in function in Geany:

Change the date format to ISO 8601:

Menu EditInsert DateSet Custom Data Format, to “%Y-%m-%dT%H%M%S”.

Usage (see above for changing the keyboard shortcut, near “Insert date and time”): Menu EditInsert DataUse Custom Data Format.

It can also be done with templates (like in UltraEdit). Setting the date/time format to ISO 8601:

Menu EditPreferences (Ctrl + Alt + P) → TemplatesDate & Time, to “%Y-%m-%dT%H%M%S”.


Persistent bookmarks

Geany does not remember bookmarks by default, making them pretty much useless. What is the point of bookmarks if they are not saved across sessions??

For this to work, the plugin “Numbered Booksmarks” must be installed. For instructions, see Is there a bookmarks feature in Geany?. General install instruction for Geany plugins. Essentially it is: apt-cache search geany on Ubuntu to get the list, and sudo apt-get install geany-plugin-numberedbookmarks to install. On Windows, it is part of the EXE plugin installer.

In the plugin manager, enable it to load at startup.

Note that even then the document must be saved before the current bookmarks are persisted. And it does not work if the document is already saved and bookmarks are added after that. Workaround: Add a trailing space somewhere (or some other change) and then save – this will save the current bookmarks. Or in other words, bookmarks may be lost if the document is not “dirtied” and then immediately saved.

Dismiss the Find dialog

Menu EditPreferences (Ctrl + Alt + P) → “General” → tab “Miscellaneous”, check “Hide the Find dialog”.

Make search wrap around

That is, also search from the beginning of the document after the last match at the end of a document (otherwise, apparent false negative search results).

Menu EditPreferences (Ctrl + Alt + P) → “General” → tab “Miscellaneous”, check “Always wrap search”.

Insert newlines when using search&replace

For find and replace, empty lines can be used in the replacement string, but it is far from obvious that it is possible. To do it:

  • Use “\n” in field “Replace with:”
  • Check option “Use regular expressions”
  • Check option “Use multi-line matching”

Or simpler:

  • Use “\n” in field “Replace with:”
  • Check option “Use escape sequences”

This feature is e.g. useful when breaking up very long lines of HTML by replacing space with newline.

Similarly, it is also possible to match newlines in the search (e.g., to find lines separate by more than one empty line).

An alternative (incl. for more complex scenarios) is to use the plugin Mini Script (see above for details). It enables to run arbitrary script code on the selection in a Geany document (passed to the script by standard input (as seen by the script)) and replacing the selection (passed from the script by standard output). For example, script code for this in Perl:

while (<>)

    s/\s/\n/g; # Replace space with newline

    print "$_\n";

Note that Mini Script does not remember the script code and thus it must be manually set up for every Geany session… The alternative is to use external commands – see near “Sort lines” below.

Changing case of text

Geany doesn’t have the same range of functions as UltraEdit, but toggling the case of the selection may be sufficient (menu EditFormat“Toggle Case of Selection” (Ctrl + Alt + U). Note: despite the name, it doesn’t toggle the case of each individual character. Instead it changes all to lower case unless all is already lowercase. This is what we want – this covers the case (no pun intended) of changing from title case to sentence case.

Map the keyboard shortcut to Ctrl + F5 (UltraEdit’s to lower case) – “Toggle Case of Selection” in section “Format” in keybindings.

Generate number series

Corresponding to UltraEdit’s “Insert Number”.

Use the Geany plugin “Insert Numbers”. Install it by “sudo apt-get install geany-plugins” and enable it in the Plugin Manager. Geany must be restarted for it to turn up in menu Tools. Note that this will install 40 other plugins, not just “Insert Numbers”.

Note that it only works on a block selection, not a normal selection. It even supports binary and hexadecimal number series.

Split windows (vertical or horizontal)

Split windows are supported, but not through standard menus. It is by the plugin “Split Window”. The plugin is part of the standard plugins package (already installed if the instructions have been followed here). Enable it using the Plugin Manager: menu ToolsPlugin Manager. After this, there is a new sub menu, menu ToolsSplit Window with commands “Side by Side” and “Top and Buttom”. Note that it is available immediately; there isn’t any need to restart Geany.

Unfortunately, it is completely broken for any practical use. Most operations, like find (Ctrl + F, F3), will not take place in the part with focus, but only in the original part (left for “Side by Side” and top for “Top and Buttom”).

Sort lines

There isn’t a built-in sort function. On Linux, external tools can used instead (that can be used directly on selected text):

Menu EditFormatSend Selection toFormatSet Custom Commands. Click “Add”. Type “sort” (it is the name of the executable on a Linux system that can take input from standard input and output a sorted version to standard output). Also fill in the “Label” field. E.g., with “Sort”.

Note 1: The “Label” field must be filled in (even if it is not actually displayed anywhere (it appears to be a bug in Geany – the intent was probably for the content of the “Label” to show up in the menu item (instead of the raw command-line)))

Note 2: With GNOME on Ubuntu, there are severe screen update problems if (ironically) the accessibility setting “High Contrast” is enabled (Win + “sett” → Settings (or System Settings) → Universal Access (or Accessibility)). Though it is sadly not a surprise when it comes to GNOME. The workaround is to switch off “High Contrast” while setting up the commands in dialog “Set Custom Commands”.

Note 3: Only the first three keyboard shortcuts are automatic, Ctrl + 1, Ctrl + 2, and Ctrl + 3.

Note 4: When making changes to a command line in the “Set Custom Commands” dialog, changes are silently discarded if the dialog is dismissed with “Esc” (there isn’t any warning). Always press “OK” or Alt + O after making changes…

Note 5: If there is a syntax error in the Perl one-liner it seems to silently fail (there isn’t any error message to the output about the syntax error). The input is cleared because nothing is output to standard output due to the error occurring. However, the error is actually displayed at the bottom of the screen in Geany. Example: “The executed custom command returned an error. Your selection was not changed. Error message: Bareword found where operator expected at -e line 1, near “qx/export””

To exclude duplicates, use “sort -u” instead of “sort”. They can be two separate commands.

The sort can be invoked much the same way as it was defined, but it is much easier to use the automatic keyboard shortcuts, Ctrl + 1, Ctrl + 2, etc.

Note that, as any command-line can be used, it is very flexible and some highly specialised sort could be implemented by means of a Perl, or Python, or Bash script. It is not known how long a Perl one-liner is allowed – but in any case the command line could be running ‘perl’ on a Perl script stored in a file (thus no restrictions).

On Windows, if Perl is installed, Perl one-liners can very easily be used to achieve the same effect. Even if some system-provided commands on Windows may work with both standard input and standard output (required for use in Geany), Perl is the more general solution that always works. Use Strawberry Perl.

Open URLs in selected lines in a web browser

As for “Sort lines”, this Perl one-liner can be used (it limits the number of opened URLs to 50, in case way too many lines with URLs are selected…):

perl -e 'my $maxURLs = 50; my $inputCount = 0; my $outputCount = 0; while (<>) { $inputCount++; chomp; print "$_\n"; if ($outputCount < $maxURLs) { if (/(http[^\s\>]+)/) { $outputCount++; $URL = $1; system("xdg-open \"$URL\""); sleep(3); } } }'

On Windows, it is very similar. Only the system call, start instead of xdg-open, is different and on Windows double quotes are used instead of single quotes for the Perl one-liner itself, so using literal double quotes and ‘\n’ in the Perl one-liner is more cumbersome (an alternative is to use a Perl script (committed to disk)):

perl -e "my $maxURLs = 50; my $inputCount = 0; my $outputCount = 0; while (<>) { $inputCount++; chomp; print $_ . chr(10); if ($outputCount < $maxURLs) { if (/(http[^\s\>]+)/) { $outputCount++; $URL = $1; $quot = chr(34); system('start ' . $quot . $quot . ' ' . $URL); sleep(3); } } }"

Gotcha: The default browser, e.g. Firefox, should already be running when invoking the command. Otherwise, Firefox will launch, but Geany becomes unresponsive! Geany will be a zombie until Firefox is closed. If Firefox is already open when invoking, Geany is unaffected.

Converting between binary, octal, decimal, and hexadecimal numbers

UltraEdit has the Number Converter window (it is not a menu command, but it is invoked through the context menu in a text document and is only available if there is selected text):

UltraEdit's number converter

Geany doesn’t have anything built-in, but it can be achieved through a custom command with a Perl one-liner. For example, to convert from octal numbers that are constrained to eight bits:

perl -nle 'my $number = oct($_); my $binStr = substr(unpack("B32", pack("N", $number)), 24, 8); my $asHex = sprintf("0x%X", $number); if (/\d/) {print "$binStr  $_  $number  $asHex"} else { print } '

See section “Sort lines” on how to add it to the custom commands. If the one-liner is one of the first three custom commands, it automatically gets a keyboard shortcut, Ctrl + 1, Ctrl + 2, or Ctrl + 3, depending on the ID/order.

One advantage is the complete freedom in how the output should be formatted. For instance, it could output in both binary, octal, decimal, and hexadecimal (in UltraEdit, only one number base is output at a time). Another is that, in contrast to UltraEdit where it is more like a calculator and only one value can be converted at a time, it works on the selected lines – any number of numbers can be converted.

Column mode blues

On Lubuntu, the keyboard shortcuts for selecting a rectangular area of text (“column mode” in UltraEdit) do not work, because they conflict with four default keyboard shortcuts in the window manager (LXDE? Openbox?), Shift + Alt + arrow up, Shift + Alt + arrow down, Shift + Alt + arrow left, and Shift + Alt + arrow right.

Disable the window manager keyboard shortcuts by editing file ~/.config/openbox/lubuntu-rc.xml near “S-A-Up”, “S-A-Down”, “S-A-Left”, and “S-A-Right”. For example, change “S-A-Up” to “S-A-Up99”, “S-A-Down” to “S-A-Down99”, “S-A-Left” to “S-A-Left99”, and “S-A-Right” to “S-A-Right99”, respectively. And add an XML comment as to why and document the original values (so they can more easily be reverted). Edit and update (without a restart required):

vi ~/.config/openbox/lubuntu-rc.xml
openbox --reconfigure

It was tested with Lubuntu 18.04 (32 bit).

Record and use macros

The Geany plugin “Geany Macro” may be able to do it.

Location of some Geany files

For example, for backup purposes. A lot of important state may be lost if the current tabs are lost. This can happen if the current instance Geany freezes, another instance of Geany is started, and that instance is quit (the open tabs are written at program exit). As the first instance is frozen there isn’t any way to save them…

  • Session file (with the open tabs): ~/.config/geany/geany.conf. For example, /home/mortensen/.config/geany/geany.conf. The open tabs are stored near “recent_files=”. It also stores the setup in menu EditFormatSend Selection toFormat.
  • Snippets file: ~/.config/geany/snippets.conf. For example, /home/mortensen/.config/geany/snippets.conf
  • Keyboard shortcuts file: ~/.config/geany/keybindings.conf. For example, /home/mortensen/.config/geany/keybindings.conf

Extra features not in UltraEdit

Apply own Perl scripts directly on selected text

The Geany plugin “Mini Script” (GMS) enables this. And it actually works, despite the poor documentation (missing or misleading). E.g., information (e.g., the current text selection in Geany) to the script (e.g., in Perl) is through the script’s standard input and what is output to standard output will replace the selection.

Note, however, that Mini Script does not save the configuration, so it must be set up for every session. The alternative is to use custom commands as described above in section “Sort lines”. The drawback is that there is only one line available. But it is possible to use scripts committed to disk instead. Perl one-liners can definitely be used, but it is unviable for more complicated/longer scripts.

Document tabs can be moved without using the mouse

Ctrl + Shift + PageUp moves a document tab to the left (presumes the keyboard shortcuts have been set as described above, near “Move tabs”). Ctrl + Shift + PageDown moves a document tab to the right. (The same also works in Firefox.)

Long line marker

Change it from 72 to the standard 77:

Menu EditPreferencesEditor → tab Display. Set “Column” to 77 (under “Long line marker”).

Missing features in Geany

A find next (now F3) on selected text will not search for that text, unlike in many other text editors (e.g., UltraEdit, Notepad++, and Visual Studio). This is quite cumbersome (the Arduino IDE and Visual Studio Code have the same problem). Though it may prevent the broken F3 for regular expression search in UltraEdit.

A feature to add some text to all columns in a block selection (UltraEdit’s menu Column“Insert/Fill Columns”). To look at column selection in plugin “Extra Selection”.

In newer versions of Geany (e.g., 1.36), using replace everything in a document with the same string does not display statistics about how many replaces took place (useful for counting strings in a document (by replacing it with the same string)). Geany is too smart in this case; in earlier versions of Geany (e.g., 1.27), it worked fine, not making a distinction between replacing with the same string or not. A possible workaround is to use a custom action to count the word (see section “Sort lines”). Another workaround is to make the two strings different (this will change the document, but it will be acceptable in a temporary document (that is going to be thrown away anyway). Undo (Ctrl + Z) could also be used, but it is an extra complication.)

Unexpected behaviour/bugs in Geany

Inserting the date (Alt + 3) does not replace the selection

It ought to work like a paste.

Non-standard keyboard shortcut for case sensitive in the Find dialog

It ought to be the standard Alt + C (as in Visual Studio, Notepad, and Notepad++). UltraEdit has the same problem – it uses the non-standard Alt + M (from “m” in Match case).

Replace (in the search dialog) does not replace and find next

This unlike in all other text editors. Instead, use the button Replace & Find (keyboard shortcut Alt + N).

Opening a file with long lines crashes Geany

It doesn’t technically crash, but it becomes unresponsive for an unknown (long) length of time. 10 minutes? 2 days? Longer than the heat death of the universe? Who knows. It probably needs to be killed, so it is the same effect as a crash.

It was tried on the export file (SQL) for the (MySQL) database for this very blog. It wasn’t that long, about 7 MB and 20,000 lines. But the file had some long lines, e.g., 31000 characters (it seems to be the HTML content of the blog posts as long lines (one long line per a blog post)).

By contrast, UltraEdit opens the exact same file instantly.

Search with a regular expression does not work backwards in the document

Button “Previous” is dimmed when “Use regular expressions” is checked.

It at least ought to work on a line-to-line basis (go back one line, search forward – in most cases it wouldn’t matter if it only indicated the first match on a line).

UltraEdit does not have a problem searching backwards, so it ought to work in Geany as well.

See also

Geany HowTos (Geany wiki)

Convert CamelCase to lower_case_underscore and vice versa (Geany wiki). Uses Python and custom commands.

User-definable snippets (Geany user manual)

0 Comments on “Using Geany as a replacement for UltraEdit

Leave a Reply

Your email address will not be published. Required fields are marked *