Home Download Buy Blog Forum Support

Copy matching lines

Copy matching lines

Postby cmulcahy on Tue Jun 12, 2012 1:01 pm

Hi. I want to write a plugin, unless it already exists, that copies lines from the current document that match a regex into a new document.

Does such a plugin already exist? If not, I'll see about starting my own first plugin. I'll undoubtedly be back with questions.

Posts: 4
Joined: Sun Jan 23, 2011 7:41 pm

Re: Copy matching lines

Postby jbjornson on Tue Jun 12, 2012 1:34 pm

I'm not sure this really warrants a plugin. All you need to do is a reg-ex search, click find all, press the right arrow to move the cursors to the end of the selections and then ctrl-c to copy the matching lines. Multiple selections are one of the coolest and most underrated parts of this application.
Posts: 359
Joined: Tue Oct 27, 2009 4:25 pm
Location: Zurich, Switzerland

Re: Copy matching lines

Postby guillermooo on Tue Jun 12, 2012 10:52 pm

Besides the simple method suggested by jbjornson, two existing plugins can make this a little bit easier too:

1) https://github.com/SublimeText/UberSelection
2) https://github.com/SublimeText/VintageEx

Example for (1)

Code: Select all

("Select all lines where regex1 matches and regex2 doesn't match.")

Examples for (2)

Code: Select all

("Select all lines where regex matches and print them to a separate buffer along their line nr. and show all whitespace.")

Code: Select all

("Select all lines where regex does not match, etc.")
Posts: 738
Joined: Thu Jul 23, 2009 9:06 am

Return to Plugin Development

Who is online

Users browsing this forum: No registered users and 5 guests