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,614 times
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