Remove lines
-
Hello, i need help with removing lines for example i have 2 text files and i want to remove lines that already exist in file 2 from file 1. it should look like this
file 1 lines
awd
awda
awdd
awddd
awdddd
awdddddfile 2 lines
awd
awda
awdd
and after removing it should look like this
awddd
awdddd
awddddd -
if you have or don’t bother installing python script plugin then a script like this might do what you want
Open File 1 and 2 and move file 2 into the other view(right click on tab and select Move to Other View)e1 = editor1.getCharacterPointer().splitlines() e2 = editor2.getCharacterPointer().splitlines() new_content = [] for line in e1: if line in e2: continue new_content.append(line) editor1.beginUndoAction() editor1.setText('\r\n'.join(new_content)) editor1.endUndoAction()
-
Hello, @icrack, @eko-palypse and All,
@icrack, it has been already discussed many times ! Just refer, for instance, to the link, below, if you prefer a built-in solution, without any plugin needed :
https://notepad-plus-plus.org/community/topic/16335/multiline-replace-multiple-hosts-in-hostsfile/4
Best Regards,
guy038
-
don’t forget how difficult it can be to guide people to a manual pythonscript install nowadays.
even after peter’s and my multiple step by step guides for installed and portable versions (which i currently just copy and paste repeatedly for the respective versions) many people still download eg. the msi or from a different source than the 1.3.0.0 of the guides, don’t get it to work, reinstall notepad++ completely with a different version and/or architecture, and repost after that, so that sometimes we had to start guiding from zero again.
-
I like Eko’s solution because since it doesn’t use regex, we can’t have a regex “screwup” (i.e., all text becoming selected in a file). :)
-
i second that, i like it too.
a few weeks ago i thought installing pythonscript is easy to install for anyone anyways, even on 7.6-7.6.3.
but recent events, where people were given a step by step guide, and then answered that they did something completely different, probably because it was written to do so at the developers installation guide, and nothing works, made me re-think that a bit for now.currently i have this “self fulfilling prophecy” state of mind, when it comes to guiding standard users with a pythonscript plugin install, but i hope that goes away as soon as there are at least one or two users that actually managed to get it running at the first try 😉
-
You tell people to do something, then they do something completely different? Hmmm, I think I would quit trying. I’ve already got my own little children to raise up!