Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    [solved] renaming include files...any way to automate editing?

    QML and Qt Quick
    2
    4
    1853
    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.
    • mzimmers
      mzimmers last edited by

      So, let's say I have an include file that I wish to rename, and its old name is already scattered through many source files. Is there a way to automate this within Creator, or am I stuck with good old cut-and-paste?

      I'm sure I could do it with a shell script, but...I haven't done that stuff in decades.

      Thanks.

      1 Reply Last reply Reply Quote 0
      • G
        goetz last edited by

        Just use the global search/replace. Cmd-Shift-F (you're on a Mac, aren't you? :) )

        Then enter

        #include "myoldinclude.h"

        in the search field, enter * into the file pattern, check case sensitive, search in all projects and click on the "search & replace" button. You'll get a list of the files and the lines that match and on top you can enter the replacement

        #include "mynewheader.h"

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

        1 Reply Last reply Reply Quote 0
        • mzimmers
          mzimmers last edited by

          Thanks, Volker. Now that you've shown it to me, I can see that it's available through Edit->Find/Replace->Advanced Find. (It's easier for me to remember the menu paths than all the meta-key commands.) I see it can be used on symbols as well as text, though the "Search & Replace" button is ghosted out for that option.

          This is a very handy feature; thanks for showing it to me.

          1 Reply Last reply Reply Quote 0
          • G
            goetz last edited by

            For symbols, there is a more convenient (and safe!) way: go to the symbol you want to rename and hit Cmd-Shift-R (or choose refactoring / rename symbol from the context menu). In case the symbol is used in the current file only, you can edit in-place, in case it's spread over multiple files, a search result tab similar to that of the globals search/replace pops up. This way renaming a symbol is much more safe, as it works on the parsed C++ code (and you do not need to take care of such problems like renaming "i" to "row" and also catching "i2" and making it "row2").

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

            1 Reply Last reply Reply Quote 0
            • First post
              Last post