Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEAT: Option Box to Treat Individual Line in Replace Dialogue as Independent searches #4856

Open
rugabunda opened this issue Sep 16, 2018 · 2 comments

Comments

@rugabunda
Copy link

rugabunda commented Sep 16, 2018

I am working with a hosts file A, which has 50 alphanumerically sorted entries I want, and 49,950 I don't want. I have hosts file B, which has only the 49,950 entries I don't want. I want to use the contents of file B to remove the contents from File A that I don't want. Currently this can only be done with regex S/R expressions. Currently I can search for one line at a time, and replace that no problem, but I can’t just as easily insert the entire hosts lists from file B and replace them all at once. It should be that simple imo. A simple check box to treat each individual contiguous line as its own search & replace in ascending order would be extremely valuable, and would save a lot of people a lot of time and searching around to find the proper expressions.

This problem has been already discussed many times ! So :

You have a first file, named File_A.txt, which contains a list of… whatever you like

You have a second file, named File_B.txt, which contains the same kind of list, with fewer lines than in File_A.txt

And you would like to delete, in File_A.txt, all the lines, which are, ALSO, present in File_B.txt

Wouldn’t you ?

Note that the following regex S/R compares complete lines, only !

Here is the method :

Start Notepad++

Copy/paste all contents of the main File_A.txt file in a new tab

At the end of this main list, add a new line of, at least 3 dashes ( --- )

now, append all contents of the File_B.txt file, AFTER this line

Open the Replace dialog ( Ctrl + H )

Select the Regular expression search mode

Tick the Wrap around option

SEARCH (?-s)^(.+\R)(?=((?s).+?\R)?\1)|(?s)^---.+

REPLACE Leave EMPTY

Click, once on the Replace button or several times on the Replace
Et voilà ! In the new N++ tab, any line, which was, both, present in the two files, has been deleted, as > > well as any possible duplicate lines, in the main File_A.txt file !

After performing the regex S/R :

SEARCH (?-s)^(.+\R)(?=((?s).+?\R)?\1)|(?s)^---.+

REPLACE Leave EMPTY

Details here: https://notepad-plus-plus.org/community/topic/16335/multiline-replace-multiple-hosts-in-hostsfile

@rugabunda rugabunda changed the title FEAT: Option Box to Treat Individual Lines in Replace Dialogue as Independent searches FEAT: Option Box to Treat Individual Line in Replace Dialogue as Independent searches Sep 16, 2018
@rugabunda
Copy link
Author

rugabunda commented Sep 16, 2018

Here is a great example of where the simplicity of this would be extremely useful; taking multiple combined alphanumerically sorted lists, and organizing/separating them by file or by line/section! This is common practice. Having this functionality largely automated, as suggested above would be superb!

@Rainald62
Copy link

This would be a feature for less than 0.001 % of users. The mere presence of another checkbox with label would bother 99.999 % of users.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants