10

I want to find a text editor capable of running and mainly storing regular expressions for later re-use. It should also be able to run them across multiple files.

I know I can get all that with grep, but there is not much for re-use on it. I was able to get some regular expression functionality on Gedit with plugins, but not nearly close to my needs.

There is EditPad Pro for Windows (runs on wine) but native is always better :)

8 Answers 8

18

The two classic open source Unix editors are GNU emacs and (g)Vim and both work fine on Ubuntu. They both have more features than you can learn about in a lifetime, including what you're after. There are plenty of others two too, but you might as well start with the best. (I'll try not to get into which of these is better, since it's already an epic holy war.)

By the way, sed is probably a better alternative than grep for RegEx manipulations from the commandline, and you can write and save scripts for it. (Of course you can use perl, awk and python for reg ex too.)

Some inspiration from xkcd: http://imgs.xkcd.com/comics/real_programmers.png

3
  • 2
    I hate to be that guy, but 'too', not 'two'.
    – TJ L
    Aug 27, 2010 at 13:46
  • D'oh! Sorry about the typo. Don't worry. I'm usually that guy. I had meant to mention that if you want to stick with gEdit, you could install its nice External Tools plugin and use that to run sed scripts on the buffer.
    – frabjous
    Aug 27, 2010 at 15:15
  • @tj111 - Never apologize for being detail oriented. In our line of work, it'd be worrisome if you DIDN'T think it was important. :-) Mar 1, 2015 at 19:20
15

Geany has a good set of find:

geany find

replace:

geany replace

and file searching:

geany grep

features. It doesn't have any inbuilt ability to save regular expressions for later although you could always store them in a text file.

It does have history for find/replace but this is limited to one session.

1
  • 1
    Much easier to just use Geany when you need a quick GUI editor with regex support, rather than having to dig through the internet and man pages to learn the syntax for regexes in vi(m) Jan 7, 2014 at 17:06
6

If you just want to run regex against a bunch of files, I think it's time for you to learn about sed and awk

1
  • You can save and edit the scripts in a file with sed or awk too.
    – pbhj
    Jan 21, 2018 at 21:36
2

You can use a combination of GEdit and the plugin Advanced find / replace plugin for gedit that you can find in http://code.google.com/p/advanced-find/.

From 2012 it has the feature of bookmark an expression so you can reuse it. Also it can search and replace for opened files, for files in a folder (with a filter) or inside a text selection.

About how to install, you can follow the instructions in its wiki page http://code.google.com/p/advanced-find/wiki/Installation.

Basically what you must do is:

  1. Download the correct version for your gedit from http://code.google.com/p/advanced-find/downloads/list.

  2. Decompress it.

  3. Run install.sh (without sudo).

  4. Go to preferences / plug-in and activate it.

Screen capture of Advanced Find/Replace dialog opened

1

I wanted to add a comment pointing to this answer, but since apparently I don't have enough reputation for that, I'll duplicate it here as an answer of my own: RegExr is the best tool I've ever used for text manipulation using regular expressions. It will even explain each part of the regex for you!

It is an online tool, but there's a desktop version. This uses Adobe AIR, which has been discontinued for Linux, so you might need to install it following these excellent step-by-step instructions. After that, download the .air file for RexExr desktop page linked above, and you should be able to open it with the AIR installer. Then edit away!

1

I'm really surprised nobody mentioned 'medit'... search/replace has simple check box telling medit that the criteria you entered is a regex expression... can be as simple or complex as you like..

1
  • Welcome to AskUbuntu. It would be more useful if you could elaborate the answer with examples and/or screenshots.
    – Sri
    Jan 6, 2015 at 5:43
0

Atom has this function. Download and install the "deb" package.

Press CTRL + F and click the .* button to go into regex mode.

Alternatively, you can press CTRL + ALT + /

Also on github.

Related question on how to use regex in atom.

Or you can use cat and sed.

Use sed -e to simply print the changes. Use sed -i to actually edit the contents of the file.

See here for more info.

You can also use egrep to use regular expressions with grep.

If you just need find replace functions, gedit accepts regular expressions if you press CTRL + F.

You can also do regular expressions in vim.

0

Eclipse is best though a bit heavy for the purpose. All findings are available in a separate pane. (skeleton) You can jump immediately to any of them.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .