Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. [solved] renaming include files...any way to automate editing?
QtWS25 Last Chance

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

Scheduled Pinned Locked Moved QML and Qt Quick
4 Posts 2 Posters 2.0k Views
  • 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.
  • mzimmersM Offline
    mzimmersM Offline
    mzimmers
    wrote on last edited by
    #1

    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
    0
    • G Offline
      G Offline
      goetz
      wrote on last edited by
      #2

      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
      0
      • mzimmersM Offline
        mzimmersM Offline
        mzimmers
        wrote on last edited by
        #3

        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
        0
        • G Offline
          G Offline
          goetz
          wrote on last edited by
          #4

          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
          0

          • Login

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