I have a text file. Can Emacs select text based on regex and put it in kill-ring, so I can copy it somewhere else? Something like regex-kill-ring-save?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
inspired by the already given comments (the Charles answer doesn’t work as I would want it), I added a new function to the isearch/isearch-regexp mode map which puts only the matching string into the kill ring (whereas Charles proposal kills from current point to end of matching string):
The nice thing about the isearch/isearch-regexp approach (which you can enable with
C-sandC-M-srespectively) is that you can see your search string growing and you can copy it withM-was soon as you are satisfied (and go back to where you have been before withC-u C-Space).This works for me with Emacs 23.1. Don’t know if it will work in all situations. Anyway I hope you find it useful 🙂
UPDATE: going through the emacswiki I stumbled over KillISearchMatch which suggests more or less the same (plus some more tips …).
Cheers,
Daniel