I have an extremely long text file (about 15k lines). It only contains numbers (6 numbers separated by a space). I am only interested in the first three numbers of each line. I have tried the column mode selection and drag it down, however it's very slow, and I have several files to handle.
I have also tried the Begin/End Selection trick, however it doesn't seem to work with columns.
Is there a way to automatically select only the three last columns of numbers in a text file ? One way it could would be an option to select all lines in specified column(s). Is it possible whatsoever ?
72 Answers
Try this:
- Press CTRL+Home to move the typing cursor to the top of the document.
- Now, use the scroll bar to rapidly scroll to the bottom of the document without changing the position of the typing cursor. You can drag the slider portion of the scroll bar to rapidly reach the bottom of the document. It is really fast.
- Move your mouse pointer after the third number of the last line, hold down Alt+Shift and click.
Bingo!
0This can be done with the following regular expression, assuming your numbers are numbers only (ie. no commas, decimal points):
1111 2222 3333 4444 5555 6666
1111 2222 3333 4444 5555 6666
1111 2222 3333 4444 5555 6666
1111 2222 3333 4444 5555 6666
1111 2222 3333 4444 5555 6666
1111 2222 3333 4444 5555 6666
1111 2222 3333 4444 5555 6666
1111 2222 3333 4444 5555 6666CTRL-H to go to Find and Replace
Find what: .*\s(\d+\s\d+\s\d+)$
Replace with: \1
Search Mode: Regular expressionAn explanation of the find regex:
.* = match anything, repeating
\s = match single whitespace
( = start capture group
\d+ = match one or more numerals
\s = match single whitespace
\d+ = match one or more numerals
\s = match single whitespace
\d+ = match one or more numerals
) = end capture group
$ = match end of lineAnd the replace box:
\1 = capture group 1 from the prior regex match (everything matched between the ( and the ))This took a few seconds to replace and leaves you with the last three columns of numbers, ie.
4444 5555 6666
4444 5555 6666
4444 5555 6666
4444 5555 6666
4444 5555 6666
4444 5555 6666
4444 5555 6666
4444 5555 6666
4444 5555 6666
4444 5555 6666
4444 5555 6666Screenshot of NPP replace box: