Skip to content

Instantly share code, notes, and snippets.

@hadashiA
Created June 18, 2012 16:14
Show Gist options
  • Save hadashiA/2949159 to your computer and use it in GitHub Desktop.
Save hadashiA/2949159 to your computer and use it in GitHub Desktop.
vimperator plugin: copy to clipboard for Regexp matched HTML text content
(function () {
commands.addUserCommand(
['rcopy'], 'Copy for Regexp match string',
function(args, bang, count) {
var text = (function (e, re) {
var m = e.textContent.match(re);
if (m) return m[0];
for (var i = 0; i < e.children.length; i++) {
var result = arguments.callee(e.children[i], re);
if (result) return result;
}
return null;
})(content.document.body, new RegExp(args.string));
if (text) {
liberator.echo('CopiedString: `' + text + "'");
util.copyToClipboard(text);
}
});
})();
// add your .vimperatorrc
// noremap ,pa :rcopy PA\d{8}<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment