Find and Replace in Selected Text


I commonly use the same find and replace for plain text. Is there a way to select text and hit a trigger in BTT to start up a simple find and replace in the selected text?

My specific situation has me converting html encoded URLs back to decoded URLs hundreds of times a day.


Unfortunately I haven't gotten to that feature yet, it has been on my todo list for quite a while. I hope this will become possible very soon.


With Automator you can however relatively easy create a quick action that does this:

You can then assign a keyboard shortcut to the quick action in System Preferences =>Keyboard => Shortcuts and trigger it in BTT if you want.

(For some reason it's necessary to concatenate an empty string with the input first, otherwise it will throw an error.)


It also works using BTT when doing it like this:

The shell script action would be configured like this:

osascript  -l JavaScript <<\EOF

var BetterTouchTool = Application('BetterTouchTool');
BetterTouchTool.includeStandardAdditions = true;

var result = BetterTouchTool.get_string_variable("selected_text");

result = result.replace("test", "replacement");


Instead of the replace, you can also use the JavaScript url decode/encode functions.


Thank you for your quick reply. I was not able to get this working. I did find this page from Apple, do you think this might hold the key to the answer?


When I replaced the text with the encoded text (eg: & a m p ; ), there seems to be an issue with the semi-colon.


I was able to solve this issue by using TextSoap. I applied a keyboard shortcut that is triggered by the touch bar. It seems to work flawlessly.