I use a regex to find a piece of text. Is there a way of programming a shortcut to copy the found piece of text (and nothing else) to the Windows (or any other) clipboard? If I find text and press “ctrl-C” what goes to the clipboard is the regex, not the found (matched) text.
If Sublime Text has no facility for this, is there any other text editor that provides this?
Shortcut to copy or cut matched text to clipboard
You could probably write a plugin or use a macro to do this, but be aware that a regex can return multiple matches (in fact, this is common). What would you output to the clipboard in this case?
The simplest thing might be to run the regex, chose ‘Find all’, then copy. Your copy buffer will now include all matches, separated by a newline.
If this gives you the results as you need, you could a record this a macro, to save a few clicks/key presses. You will need to couple it with the RegReplace ST package, that allows you to save and chain different regex searches (and optional replaces).
if, after you’ve written your regex, in ‘find box’.
click at the beginning of your document, so focus in on the document then F3 or click ‘find’ button and Ctrl+C works on the document, not the ‘find box’
To keep your hands on the keyboard (not back and forth to the mouse), after writing regex, hit ESC and F3 then Ctrl+C, F3 again, again, etc…
LandisTwo.