Community
    • Login

    Open a new Notepad++ Window/Session and run Find All in All Opened Documents from command line

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    11 Posts 3 Posters 87 Views
    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.
    • Thomas ZitoT
      Thomas Zito
      last edited by Thomas Zito

      e.g. you are searching for certain strings in the same group of files like select statements or function method calls or hardcoded string names and want to just open all the files in a new window. Any improvements that can be made?

      i.e.
      findstr /SIM “\my_class::database()->select(” .
      then you copy paste all the results into <files> below.
      Or you can pipe it, maybe.
      notepad++ -titleAdd=“Drupal::database()->select” -nosession -multiInst <files>

      Create a new window.
      addTitle=“search string”
      Open all found files in same window.
      Examine files.
      Repeat for another search

      in theory I should make a table where search strings are the columns and files are the first column, and place a check… well, that makes searching become its own project.

      Anyway this is what i thought of

      notepad++ -titleAdd=“aclass::database()->select” -nosession -multiInst project_a\includes\form.php project_a\includes\model.php

      (so that’s the dumb way)

      I wanted to do a smarter way, by running findstr and collecting its results into a list of arguments to pass to notepad++. All you have to do is fill out the search_term. if there are spaces it could be an issue with double quotes, didn’t test that. Other issue is that you can’t see how many search results there are and confirm beforehand and personally, I prefer to type in my search term afterward… well, its ok.

      cmd /v:on /c "set search=search_term & set args= & (for /f %F in ('findstr /SM !search! *.*') do set args=!args! "%F" & set args=!args!) & start notepad++ -titleAdd=!search! -nosession -multiInst !args! & echo !args!"
      
      PeterJonesP 1 Reply Last reply Reply Quote 0
      • PeterJonesP
        PeterJones @Thomas Zito
        last edited by

        @Thomas-Zito said in Open a new Notepad++ Window/Session and run Find All in All Opened Documents from command line:

        I’m trying to use this script to open some search results from command line in a new notepad++ window

        “This script” = What script? The one in this topic – if so, why did you create a brand new topic rather than replying to that. If not, you need to give better context. (The only reason I thought to look there is because of you making multiple posts in a row all about similar things. If this really is discussing the same thing as that other post, do you want the two discussions merged, so that people can follow your conversations without huge, annoying confusion?)

        I’d like to make it so it also runs Find->Find All in All Opened Documents->search_term automatically

        internal find/find-all commands cannot be run using command-line options. I believe that’s been requested before, but cannot remember whether it’s just one that the developer isn’t interested in, or outright rejected. You’d have to search the open and closed issues in the issue list at github, as described in our feature request FAQ.

        Is there a way to automate this using sessions?

        Sessions don’t store search results. Loading a session file could be used to open a specific list of files.

        1 Reply Last reply Reply Quote 1
        • Alan KilbornA
          Alan Kilborn @Thomas Zito
          last edited by Alan Kilborn

          @Thomas-Zito said:

          I’m trying to use this script

          Which script??


          …open some search results from command line in a new notepad++ window
          I’d like to make it so it also runs Find->Find All in All Opened Documents->search_term automatically

          So you want, when the new instance starts up, to run FAiAOD immediately, with some search-term that is specified on the command line used to run the new instance?

          This seems doable; I’m thinking via PythonScript (because that’s how I do such nonstandard things).

          When user startup.py runs, you’d have to detect that the search term is present on the command line, invoke the Find window, locate the Find window, set its options up, and “press” the FAiAOD button, all programmatically.


          Is there a way to automate this using sessions?

          I’m not sure why you’re bringing sessions into this??

          Thomas ZitoT 1 Reply Last reply Reply Quote 1
          • Thomas ZitoT
            Thomas Zito @Alan Kilborn
            last edited by Thomas Zito

            @Alan-Kilborn Sorry, yes, that script here. Forgot to put it in.

            As far as sessions -wasn’t sure if it supported that.

            @PeterJones : Yes, that would be good to merge. Sorry about that.

            PeterJonesP Alan KilbornA 2 Replies Last reply Reply Quote 0
            • PeterJonesP
              PeterJones @Thomas Zito
              last edited by

              @Thomas-Zito

              Any improvements that can be made?

              Does it work for you? If no, then maybe there can be. If yes, then why does there need to be? Can you be more specific about what failings you think exist in your script?

              I guess the only generic improvement that I can think of, if your scripting skills are up to the task, is writing a session XML file searchResultSession.xml that you can notepad++.exe -titleAdd="xyz" -nosession -multiInst -openSession searchResultSession.xml` – because if your search results have long paths for the files, your current script will probably hit the windows command-line character limit.

              Alan KilbornA 1 Reply Last reply Reply Quote 1
              • PeterJonesP
                PeterJones @Thomas Zito
                last edited by

                @Thomas-Zito said in Open a new Notepad++ Window/Session and run Find All in All Opened Documents from command line:

                Yes, that would be good to merge. Sorry about that.

                Ugh. I merged it, but it did it in the strange order, so now the one from yesterday comes after your original post, but in between. I am regretting this. :-(

                1 Reply Last reply Reply Quote 0
                • Alan KilbornA
                  Alan Kilborn @Thomas Zito
                  last edited by Alan Kilborn

                  @Thomas-Zito said:

                  Sorry, yes, that script here<link>. Forgot to put it in.

                  I click the link; I get “Access denied”. :-(
                  EDIT: Oh, wait…maybe caused by the moderator merge… :-)

                  PeterJonesP 1 Reply Last reply Reply Quote 0
                  • PeterJonesP
                    PeterJones @Alan Kilborn
                    last edited by

                    @Alan-Kilborn said in Open a new Notepad++ Window/Session and run Find All in All Opened Documents from command line:

                    I click the link; I get “Access denied”. :-(

                    That’s because the two topics were merged to here. The script he was linking to is now in the second post in this topic. (Sorry, trying to help made things worse, and trying to undo it will cause even more problems, so we’re stuck in this non-ideal situation.)

                    Alan KilbornA 1 Reply Last reply Reply Quote 1
                    • Alan KilbornA
                      Alan Kilborn @PeterJones
                      last edited by

                      @PeterJones said:

                      -openSession searchResultSession.xml

                      OK…that might be a reason to bring “sessions” into this discussion.

                      1 Reply Last reply Reply Quote 0
                      • Alan KilbornA
                        Alan Kilborn @PeterJones
                        last edited by

                        @PeterJones said:

                        The script he was linking to is now in the second post in this topic.

                        OK.

                        I think the use of “script” for that (OP’s usage, not Peter’s) is a bit confusing.
                        It’s just a command-line invoking Notepad++, albeit a rather complex one.
                        I understand that it could be called a “shell script”, of course.

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post
                        The Community of users of the Notepad++ text editor.
                        Powered by NodeBB | Contributors