Community
    • Login

    Delete specific lines in file

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    6 Posts 3 Posters 2.1k Views 1 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Raoul EmilR Offline
      Raoul Emil
      last edited by Raoul Emil

      Hello, i have a very long file and i want to search for specific lines and delete them. The lines i want to remain are the ones with the numbers [0], [1] and [2]. The rest [3],[4],[5] and [6] i want to delete but anyway in my file i have more than this, this is just an example.

       low_intensity_minimum[0]: &12431270
       low_intensity_minimum[1]: &31025270
       low_intensity_minimum[2]: 3
       low_intensity_minimum[3]: &310531270
       low_intensity_minimum[4]: &31352270
       low_intensity_minimum[5]: &31531270
       low_intensity_minimum[6]: &315661270
      
       dark_adaptation_speed[0]: 7
       dark_adaptation_speed[1]: &2f532531
       dark_adaptation_speed[2]: &3f154511
       dark_adaptation_speed[3]: &37373737
       dark_adaptation_speed[4]: 1
       dark_adaptation_speed[5]: &262462
       dark_adaptation_speed[6]: &2624624
      
       wind_type[0]: 2
       wind_type[1]: 1
       wind_type[2]: 0
       wind_type[3]: 0
       wind_type[4]: 2
       wind_type[5]: 1
       wind_type[6]: 2
      
       cloud_shadow_texture[0]: "/model/skybox/clouds_shadow/textures/clouds_shadow_rain2.tobj"
       cloud_shadow_texture[1]: "/model/skybox/clouds_shadow/textures/clouds_shadow_rain1.tobj"
       cloud_shadow_texture[2]: "/model/skybox/clouds_shadow/textures/clouds_shadow_rain4.tobj"
       cloud_shadow_texture[3]: "/model/skybox/clouds_shadow/textures/clouds_shadow_rain2.tobj"
       cloud_shadow_texture[4]: "/model/skybox/clouds_shadow/textures/clouds_shadow_rain1.tobj"
       cloud_shadow_texture[5]: "/model/skybox/clouds_shadow/textures/clouds_shadow_rain5.tobj"
       cloud_shadow_texture[6]: "/model/skybox/clouds_shadow/textures/clouds_shadow_rain4.tobj"
      
       fog_color[0]: (&373fad2e, &37732161, &337744fd)
       fog_color[1]: (&3wegad2e, &37732161, &43744fd)
       fog_color[2]: (&3752d2e, &37732161, &37d744fd)
       fog_color[3]: (&373fad2e, &335232161, &37d5244fd)
       fog_color[4]: (&373fad2e, &37232161, &37d744fd)
       fog_color[5]: (&37322e, &37732161, &37d2644fd)
       fog_color[6]: (&373fad2e, &326332161, &326744fd)
      Mark OlsonM 1 Reply Last reply Reply Quote 0
      • Mark OlsonM Offline
        Mark Olson @Raoul Emil
        last edited by

        @Raoul-Emil
        Find/replace form, go to the Mark tab (Ctrl+M using default keyboard shortcuts)

        Settings:
        Bookmark line: ON
        Purge for each search: doesn’t matter (I recommend on; it’s a useful default)
        Backward direction and Match whole word only: disabled b/c using regular expressions
        Match case: doesn’t matter
        Wrap around: on
        Search mode: Regular expression

        FIND: \[[012]\]:
        This will match an open squarebrace, the digit 0, 1, or 2, a close squarebrace, and a colon
        Click the Mark All button. This will bookmark the lines that you want to keep.
        From the main menu: Search->Bookmark->Remove Non-Bookmarked lines

        This will remove all the lines you don’t want.

        Raoul EmilR Mark OlsonM 2 Replies Last reply Reply Quote 2
        • guy038G Offline
          guy038
          last edited by guy038

          Hello, @mark-olson, @raoul-emil and All,

          Mark, in your reply to @raoul-emil, I suppose that the string to find and mark is :

          [\\[012\\]]:    ( and not [[012]]: )

          Best Regards,

          guy038

          P.S. :

          To understand your error, refer to :

          https://community.notepad-plus-plus.org/topic/21925/faq-desk-formatting-forum-posts

          1 Reply Last reply Reply Quote 1
          • Raoul EmilR Offline
            Raoul Emil @Mark Olson
            last edited by Raoul Emil

            My columns are from [0] to [30]. If i want to find by using [[012]]: expression, there will be also marked the numbers [10],[11] and [12] , but i want them deleted.
            I want to mark only the rows with [0], [1] and [2].
            Anyway,i can mark with normal text,no need for regular expression. But i didn’t know about the mark feature.

            1 Reply Last reply Reply Quote 1
            • guy038G Offline
              guy038
              last edited by

              Hello, @raoul-emil, @mark-olson and All,

              Ah…, OK. In that case, search and mark, using this regex syntax :

              \\[0\\]|\\[1\\]|\\[2\\]

              Best Regards,

              guy038

              1 Reply Last reply Reply Quote 3
              • Mark OlsonM Offline
                Mark Olson @Mark Olson
                last edited by

                @Mark-Olson said in Delete specific lines in file:

                FIND: [[012]]:

                Yeah, I’m aware that my regex was wrong.

                I intended to enter \\[[012]\\], but apparently even after the recent upgrades to the forum it still has the issues with escaped squarebraces.

                I had to test to see if the issue was still there, but didn’t have time to fix my post after it came out wrong.

                1 Reply Last reply Reply Quote 3

                Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                With your input, this post could be even better 💗

                Register Login
                • First post
                  Last post
                The Community of users of the Notepad++ text editor.
                Powered by NodeBB | Contributors