I'm looking for a GUI text editor that is capable of doing a multiple-pattern search and replace all at once. If the source would be a text file, it can be done in command line mode with sed
, but the text comes from the clipboard (no other way possible).
I need to: paste the text from the clipboard (5-50 words at most) in text editor, hit the 'replace' button with a set of 10 predefined replace patterns, and copy the result to the clipboard. This sequence will be done about 3000 times…
Best Answer
...why not use a script? Check
xclip
(sudo apt-get install xclip
)will send the clipboard to standard output, and with
-i
you can replace the clipboard. Sowill apply the change to the selection, and now you can paste it.
If you want a graphical thing, you can embed the script with yad:
That will show you a dialog like this:
Notice that the script will both modify the clipboard (paste) buffer and print it. To embed this in an editor, for example
vim
, you can do the following:Add to your
.vimrc
:run for example gvim.
Now you copy the text, go the the editor, press F4. Choose the change you want to apply.
The text will appear in the editor. If it's ok as is, you can paste it. Otherwise
Edit the text and copy it again. (In
gvim
, you can select the text with the mouse and simply choose paste --- or learn thevim
commands, whatever).It could be optimized for sure (you probably can easily define another key to select and paste the modified text so that you have even less keypress to use)