Is there a way to use wildcards in gedit's search and replace function? I really don't want to have to install anything or try or have to figure out how to use a 3rd party plugin—I installed the advanced find and replace plugin, yet there is absolutely zero information on how to use the thing.
Asked
Active
Viewed 5,434 times
0
-
what plugin it is ? – Raja G Oct 05 '13 at 01:29
-
See http://askubuntu.com/questions/173785/install-regex-plugin-for-gedit. As for how to use it, there are two fields, search and replace and standard regex applies. – Oct 05 '13 at 01:53
1 Answers
3
Taking your question literally, there is a ridiculous/extreme way to enable wildcards without installing any additional plugins.
- First, go to edit/preferences/plugins and enable the python console. This plugin should be installed by default.
- Hit ctrl-f9 to open the bottom panel and expose the console
Paste the following code into the console and hit enter:
#function to replace stuff import re def replace(re1,re2): doc = window.get_active_document() start, end = doc.get_bounds() txt = start.get_slice(end) newtxt = re.sub(re1,re2,txt) doc.set_text(newtxt)
For demo purposes, paste the above code into your gedit document
- Now, from the console, you can use regular expressions with wildcards like so:
replace(r'function.*',r'new comment')
Pretty fun, right? :)

MattY
- 401
- 3
- 8