How do I select specific range of lines in Notepad++ quickly? I have a text file that has over 1M of lines and I need to delete some fragments from it, but selecting lines manually just takes too much time. For example: I need to select lines from 2000 to 12000, how to make it quick?
Selecting range of lines in Notepad ++
notepadtext editing
Related Solutions
Sort of a hack (sends a window message directly to the Scintilla edit control on startup), but works great:
Install NppExec plugin
Go to Plugins -> NppExec -> Execute
Enter the following code:
// ensure console stays hidden NPP_CONSOLE 0 // enable virtual spaces (cursor past end of line) outside column edit mode SCI_SENDMSG 2596 3 0 // SCI_SENDMSG == send message to Scintilla edit control // 2596 == the message we're sending is SCI_SETVIRTUALSPACEOPTIONS // 3 == send the value (SCVS_RECTANGULARSELECTION | SCVS_USERACCESSIBLE) // the default value is 1 (just SCVS_RECTANGULARSELECTION) for // virtual spaces in column select mode only // you can find these values by poking around the source code a bit, or // see http://www.scintilla.org/ScintillaDoc.html
Click the Save button at the bottom, and give the script a name
Now go to Plugins -> NppExec -> Advanced Options
On the right, under "Execute this script when Notepad++ starts", select the script name you just saved
Click OK, close/reopen Notepad++, and enjoy ;)
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.
Best Answer
I got a better answer. You could record a macro ( deleting for example
10
lines ) . Then run it several times .1) Go to
Macro > Start recording
2) hold Shift and tap Down to mark for example
10
lines . And delete them.3) Go to
Macro > Stop Recording
Now your macro is recorded, you can save it for using in the future .
4) Go to
Macro > Save Current Recording Macro...
. And save it with a name .5) Move cursor to line that you want to delete lines after that.Then go to
Macro > Run A Macro Multiple Times...
. And select your macro and run itN
times that you want.