Notepad++ - Select all lines from columns

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 ?

7

2 Answers

Try this:

  1. Press CTRL+Home to move the typing cursor to the top of the document.
  2. 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.
  3. Move your mouse pointer after the third number of the last line, hold down Alt+Shift and click.

Bingo!

0

This 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 6666

CTRL-H to go to Find and Replace

Find what: .*\s(\d+\s\d+\s\d+)$
Replace with: \1
Search Mode: Regular expression

An 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 line

And 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 6666

Screenshot of NPP replace box:

notepad++ find and replace regex

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like