Delete entire line on search and replace?



  • 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!



  • 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?



  • -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]



  • 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?



  • Ah, sorry. Actually it is Shift-Delete.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.