Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Delete entire line on search and replace?

Delete entire line on search and replace?

Scheduled Pinned Locked Moved Qt Creator and other tools
5 Posts 2 Posters 5.8k Views 1 Watching
  • 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.
  • F Offline
    F Offline
    fonzi337
    wrote on last edited by
    #1

    Hi,

    I have a large .pro file I would like to manually modify. There is a certain substring (let's say "_XYZ") that occurs on certain lines in the .pro file. I want to delete the entire line for any line that contains this substring.

    For instance, this

    /my/folder/abc1/
    /my/folder/abc_XYZ/
    /my/folder/abc/

    would match the substring "_XYZ" on the second line and delete that entire line. The result would be

    /my/folder/abc1/
    /my/folder/abc/

    Is this possible with a single operation using Qt Creator's search and replace functionality?

    Thanks!

    1 Reply Last reply
    0
    • F Offline
      F Offline
      fonzi337
      wrote on last edited by
      #2

      After some more thinking, the only way I can think of accomplishing this is to use a regular expression search string that matches on the entire line containing the "_XYZ" substring, including catching the newline character. The replace string would be "".

      Coming up with the regular expression for this is doable but not exactly quick. Are there any other ways to accomplish this?

      1 Reply Last reply
      0
      • G Offline
        G Offline
        goetz
        wrote on last edited by
        #3

        -Shift-Backspace- Shift-Delete removes an entire line in Qt Creator's editor. Unfortunately this works only if you do not have highlighted text. In that case only the highlighted text is removed. But you can hit backspace or delete in order to delete the selected text and -Shift-Backspace- Shift-Delete afterwards for the complete remaining line as a workaround.

        [Edited wrong shortcut]

        http://www.catb.org/~esr/faqs/smart-questions.html

        1 Reply Last reply
        0
        • F Offline
          F Offline
          fonzi337
          wrote on last edited by
          #4

          Hmm, Shift+Backspace doesn't seem to do anything special for me aside from acting as a regular Backspace. This is a keyboard shortcut though. How could I include this in the Replace With field when I'm doing a Search and Replace operation? Is there a way to specify keyboard shortcuts in the Replace With field?

          1 Reply Last reply
          0
          • G Offline
            G Offline
            goetz
            wrote on last edited by
            #5

            Ah, sorry. Actually it is Shift-Delete.

            http://www.catb.org/~esr/faqs/smart-questions.html

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved