4

I want to remove a column in the middle of a txt file in notepad++. The length of the file is approximate 50K+ lines so i prefer to not have to hold down a key while the cursor slowly makes its way linearly through the rows.

3

Try:

Alt + Shift + Left Click

It should draw a selection rectangle, might work for you.

| improve this answer | |
  • You have to be sure of your answer or write it in comment – yass Apr 19 '17 at 20:13
  • 1
    OP didn't specify if the columns are the same length, if they are it will work perfectly, he didn't give us too much information to work with. That's why I wrote "might". – GorangeNinja Apr 19 '17 at 20:20
  • This answer helped me a lot! Place your cursor in the top-left corner of the box you wish to delete, scroll to the end of the file, hold Alt + Shift, and carefully draw the box with the mouse. Press Del. – bendodge Jan 23 '18 at 20:43
2

I assume you have Notepad++ with the TextFX v0.26 plugin installed and you select "Regular expression" in the Replace dialog.

If your data is of the format

col1 col2 col3 col4
col1 col2 col3 col4
col1 col2 col3 col4
col1 col2 col3 col4

where the columns have no spaces and are separated by one space, then, say you wanted to remove the third column: you can search for (.*?) (.*?) (?:.*?)( .*) and replace with $1 $2$3 (the spaces are required) to get

col1 col2 col4
col1 col2 col4
col1 col2 col4
col1 col2 col4

regex101.com does a tidier explanation of the search regex than I would:

/(.*?) (.*?) (?:.*?)( .*)/
    1st Capturing group (.*?)
        .*? matches any character (except newline)
            Quantifier: *? Between zero and unlimited times, as few times as possible, expanding as needed [lazy]
     matches the character  literally
    2nd Capturing group (.*?)
        .*? matches any character (except newline)
            Quantifier: *? Between zero and unlimited times, as few times as possible, expanding as needed [lazy]
     matches the character  literally
    (?:.*?) Non-capturing group
        .*? matches any character (except newline)
            Quantifier: *? Between zero and unlimited times, as few times as possible, expanding as needed [lazy]
    3rd Capturing group ( .*)
         matches the character  literally
        .* matches any character (except newline)
            Quantifier: * Between zero and unlimited times, as many times as possible, giving back as needed [greedy]

Other regexes to achieve the same result are possible.

If your columns are of fixed width (and include spaces) or are separated by a different character then you will have to modify the search expression and replacement, but without sample data and the required result I cannot give an exact answer.

| improve this answer | |
1

I don't believe there is a way to do this in Notepad++ without downloading/installing a plugin for it. If your file is delimited, perhaps you could load it into Excel or similar software and delete the column that way?

Edit: I just thought of an interesting solution. You can alter the line scroll speed in Windows or whatever your operating system is, restart Notepad++, and then either mouse scroll or use the arrow keys. I don't know how much of a difference this will make, but maybe it's worth a shot.

| improve this answer | |
-1

You can work in column mode in Notepad ++. The option is in the Edit menu - clicking it will prompt you with the correct keyboard shortcut. I press and hold the Alt key then select the data I want to delete/edit.

| improve this answer | |
  • The OP has more than fifty thousand lines to scroll through. If you know of a way to select the column(s) all the way to the end of the document, that would be useful information. – Andrew Morton Feb 10 '17 at 17:52

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.