moltenform
Home
Previous: Maurader's
Previous: Maurader's
gedit Plugin
gedit Plugin
Next: CellRename
Next: CellRename

gedit regular expression plugin

(from a blog post I wrote in 2008. this plugin became popular, especially after it was linked to from the official gedit website)

A friend told me that gedit was missing a plugin for regular expressions. I use gedit occasionally, and so I made this plugin. Because it uses Python's full regular expression support, you can use backreferences, making it possible to do some interesting search and replace operations.

For example, in the screenshot above, the complicated-looking expresion is just saying to look for anything in the format "aaa.bbb" and replace it with "bbb.aaa". The ( ) parens in the search string designate a "capture group", and the \1 in the replace string will be filled in with the first "capture group". You can also use \0 to refer to the entire matched string.

Update

Thanks everyone for the feedback and information. Recent gedit has a built-in replace-with-regular-expression feature, so this plugin isn't needed anymore.

For gedit 3

Adam Brandizzi has forked the code and created an improved version compatible with gedit 3.

I recommend that you use his version at Bitbucket here.

Original 2008 version

To install, download from here and place the files in ~/.gnome2/gedit/plugins/. Then open gedit, choose Preferences from the Edit menu. On the plugins tab, you should see Regular Expression Replace in the list. Check to enable. Now, you should have a "Regular Expression" item in the Search menu.

This plugin is based on extensão para o gEdit by Rafael Silva. I fixed a couple bugs, cleaned up the interface, moved the menuitem to the Search menu, added backreferences support, added replace all, and added an option for case-sensitivity. Also, the search mode is now multiline, and so ^ matches the start of a line.