How to sort lines in text from 0-9 a-z to all random lines using notepad++ and emeditor
TL;DR
As of Notepad++ v7.9, Notepad++ has a feature called Randomize Line Order which does the same thing as the answer given below (i.e. it randomizes the order of lines in a given document or selection).
It can be accessed with Edit → Line Operations → Randomize Line Order.
Original Answer
From what I can gather, neither program has a native line randomization function (much less one that uses regex). However, both have the potential ability to support this kind of function via plugins.
I could not find any pre-made solutions for EmEditor unfortunately but there is a Notepad++ plugin called Python Script which supports another external script that can do basic randomization of lines from within Notepad++.
Regarding the "large" file criteria, Notepad++ may have problems with larger files (though opening a file which is ~500MB is certainly possible without issue). If you do encounter any errors, you may need to split the file into smaller chunks.
Python Script Plugin And RandomizeLines.py
First, download and install the Python Script plugin via the Notepad++ Plugin Manager:
Ex. Python Script Plugin Installation In Notepad++ Plugin Manager
Once the plugin is installed, you will need to restart Notepad++. After restarting, the plugin should appear under Plugins → Python Script.
Next, download this Python-based "npp-randomizelines" script from Github (Clone or Download → Download ZIP). Extract the file and select the RandomizeLines.py file:
Ex. RandomizeLines Master - Extracted
Copy RandomizeLines.py to your Notepad++ → Plugins → Python Scripts → Scripts folder. This may be in a different location than shown depending on your Notepad++ installation.
Ex. RandomizeLines - Notepad++ Plugins Folder
Restart Notepad++ and you should now have a Plugins → Python Script → Scripts → RandomizeLines option.
Ex. Running The RandomizeLines Script
With your original input I get the following after running the script:
Ex. Partial Script Results
B
a
c
b
4
A
Notes
-
When run, if no lines are selected, it will randomize all the lines of the currently open file. If individual lines are highlighted, it will only randomize those lines.
-
I haven't played with the Python Script plugin itself, but it's possible that you could extend the script with Python's native regex module. Regarding syntax, the plugin apparently uses a .dll version of Python 2.7.
-
If you want a similar script/plugin for EmEditor, you are probably going to have to code your own using C++. This doesn't seem like a difficult task (at least for anyone even casually familiar with C++ and simple Windows coding) but it is likely more involved than adding regex to the Notepad++ script mentioned above.
Related videos on Youtube
DeathRival
Updated on September 18, 2022Comments
-
DeathRival over 1 year
How do i sort a large text file lines to be all random.
i'm using Emeditor Notepad++
if there a way with Regular Expressions add it too if possible
Small part of example lines:
0 1 3 4 5 6 7 8 9 10 A a B b C c D d E e
Need result:
E 8 e 5 a c 9 B 1 0 b 7 3 4 A d C D 10 6
-
DeathRival over 6 yearsnot that much large max can be 500MB - 1GB txt file but it will be less like work in 10 or 20 millions lines maximum is there a way to do with emeditor because i pref using it and my most usage in emeditor even if there a script or regular expression
-
Anaksunaman over 6 yearsAs it regards EmEditor, I am not aware of any solution other than coding your own plugin in C++ to handle this. Notepad++ can handle 500MB files, though larger files may need to be split up.
-
DeathRival over 6 yearssadlly this script don't work fine with large files any solution ?
-
Anaksunaman over 6 yearsNot so far as I know for Notepad++ or EmEditor unfortunately. However, if you are willing to try it, I wrote a generic Python script that *should (hopefully) bypass the issues with large files. Basically it shuffles the file lines in batches. If you'd like to try it, you can download it here. It requires Python so there is that. I would use the 3.6.x line. Usage is e.g.
shuffle.py filename -chunk 100000
where 100000 is the lines to shuffle in one batch (you can adjust as needed). -
Anaksunaman over 6 yearsHopefully I tested it well enough and it doesn't suck. =P