Created
June 18, 2012 16:14
-
-
Save hadashiA/2949159 to your computer and use it in GitHub Desktop.
vimperator plugin: copy to clipboard for Regexp matched HTML text content
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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