⌘R
Search for selected text and replace with clipboard contents.

Script key: Search for selected text and replace with clipboard contents.

Posted by cprichard

Install

Details

Label ⌘R
Voice Over Search for selected text and replace with clipboard contents.
Script
// Script keys run short Javascripts
// For documentation and examples, visit:
// http://help.agiletortoise.com 
// Derived from http://drafts4-actions.agiletortoise.com/k/1MH

var targetText = getClipboard();
var searchText = getSelectedText();
if ( !searchText.length ) {
  alert("Nothing to find"); 
} 
else {
  alert("Find: {" + searchText + "}\nReplace: {" + targetText + "}");
  var text = getText();
  var s = new RegExp(searchText,"mig");
  var y = targetText;
  var subText = text.replace(s,y);
  setText(subText);
}

Advanced

Keyboard shortcut Control+H
Hide key Yes

Discussion

comments powered by Disqus