Community
    • Login

    Suggestion: Find in Files from command line

    Scheduled Pinned Locked Moved General Discussion
    35 Posts 12 Posters 7.7k 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.
    • Alan KilbornA
      Alan Kilborn
      last edited by Alan Kilborn

      …but something built into Npp might make me uninstall it.

      I think we’re overlooking something.
      Notepad++ isn’t a great searching tool.
      There, I’ve said it. :-)
      I await the flames.

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

        …grep…

        Maybe grep isn’t great for multiple directories that aren’t in the same tree? Too much to specify, or maybe there’s a nice way to do something like that via a config file?

        Specifying such a thing is problematic even for the best tools.
        It is a weakness for Notepad++ as well.

        Plus grep uses yare (yet another regex engine).
        The grepper in RegexBuddy allows me to pick the regex engine I want to use (typically I set it to the same one as N++, i.e., Boost).

        <start_unpaid_commercial>
        RegexBuddy really is a great value, for I think 35USD.
        </end_upaid_commercial>

        1 Reply Last reply Reply Quote 0
        • EkopalypseE
          Ekopalypse @Alan Kilborn
          last edited by

          @Alan-Kilborn - to quote the famous “how dare are you??” :-D

          To be honest, I never had a problem with it. Yes, there are better solutions, like the one I posted, but for what I use it for, it’s good enough. Maybe because I only use utf8 encoded files.

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

            @Ekopalypse said in Suggestion: Find in Files from command line:

            how dare are you?

            :-)

            N++'s searching is slow, and as previously mentioned, how does one search several different trees? Also, you can’t do anything else with it while it is conducting a search.

            It’s perfectly fine for most things (interactive find-next, find all in current file, …), but when you get into searching a lot of files, well there are other and better ways to skin that cat.

            And since that is what the beginning of this thread was about (automating an already not-great feature), I say “meh” to the original idea. Not something I’d use. But I respect those that would, and their opinions on the topic.

            EkopalypseE 1 Reply Last reply Reply Quote 1
            • EkopalypseE
              Ekopalypse @Alan Kilborn
              last edited by

              @Alan-Kilborn

              The idea is great, because then I can start a new instance easily and it is not blocking my current instance.

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

                @Ekopalypse said in Suggestion: Find in Files from command line:

                The idea is great, because then I can start a new instance easily and it is not blocking my current instance.

                If I’m considering “calling out” like that, I’ll call out to a more capable searching program. :-)
                And when that more-capable program shows me the hits and I want to go to one of them, I’ll have that program call back into Notepad++ to take me to the file and hit line.

                EkopalypseE 1 Reply Last reply Reply Quote 0
                • EkopalypseE
                  Ekopalypse @Alan Kilborn
                  last edited by

                  @Alan-Kilborn

                  I’m not sure I understand, but in the end it depends on personal preference anyway.
                  I mean, if I use Npp because of its search function, then I think I’m using the wrong tool for the job.
                  On the other hand, if I mainly edit, then it’s good to have a powerful search function like Npp has, and if it can be easily launched from Npp and doesn’t block me - all the better.

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

                    @Ekopalypse

                    Well, in theory we could put together all we know and create the desired functionality via scripting…if it isn’t picked up natively. There’d be a lot of individual pieces, but I can’t think of anything that would be a “stopper”.

                    EkopalypseE 1 Reply Last reply Reply Quote 1
                    • EkopalypseE
                      Ekopalypse @Alan Kilborn
                      last edited by

                      @Alan-Kilborn

                      Yes, that (usually) always works :-D

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

                        @Ekopalypse

                        And some of the pieces are:

                        • invoke new instance of N++ with new parameters on the command line
                        • command line pickoff of parameters (@Ekopalypse has showed us how to do this in the past)
                        • invoking of the Find in Files dialog after N++ startup
                        • filling in the fields on Find in Files with command line data
                        • starting the Find in Files running

                        So, okay, only 4 basic steps, but some of those steps have a lot of “meat” to them.

                        I don’t know that I have sufficient interest in the base topic to work up a script, but the script-writer in me thinks that writing it would be more fun than using it would be useful. :-)

                        1 Reply Last reply Reply Quote 2
                        • artie-finkelsteinA
                          artie-finkelstein
                          last edited by

                          YAREST (Yet Another Regular Expression Search Tool)

                          I use grepWin from Stefans Tools.

                          It’s FOSS, it’s also available in the PortableApps.com platform, it uses Boost (or plain text) for searching, it can be easily configured to invoke Npp at the desired found line [ grepWin :: Settings > Editor ]:

                          C:\programs\Notepad++\notepad++.exe -n%line% "%path%"
                          

                          it works well as a Run menu command:

                          <Command name="grepWin" Ctrl="no" Alt="no" Shift="no" Key="0">grepWin /searchpath:&quot;$(CURRENT_DIRECTORY)&quot; /filemask:&quot;*.*&quot;</Command>
                          

                          and I find it nicely bridges the CL/GUI divide. It took a very small amount of work (a batch file wrapper) to make it assume folder and file extension defaults as I prefer them for regular CL invocations. [But sometimes I’ll still fire up GnuWin32 grep (for one thing it’s less to type <grin>)]

                          Alan KilbornA 1 Reply Last reply Reply Quote 2
                          • Alan KilbornA
                            Alan Kilborn @artie-finkelstein
                            last edited by

                            @artie-finkelstein said in Suggestion: Find in Files from command line:

                            grepWin…it uses Boost

                            That it uses Boost’s regex engine is a bit obscure – it doesn’t seem to advertise that – is a definite plus for N++ users that are used to it for searching.

                            artie-finkelsteinA 1 Reply Last reply Reply Quote 0
                            • artie-finkelsteinA
                              artie-finkelstein @Alan Kilborn
                              last edited by

                              @Alan-Kilborn
                              I don’t think the author considers it a major selling point; to many people RE is RE, right up until they get bitten by the flavor differences.

                              The author states on the mini help page on his website:
                              grepWin uses the boost regex engine to do its work, with the Perl Regular Expression Syntax.

                              The F1 help screen in grepWin has links to the top-level (non version specific) Boost documentation (which as of today has ‘release’ resolving to ‘1_77_0’):

                              https://www.boost.org/doc/libs/release/libs/regex/doc/html/boost_regex/syntax/perl_syntax.html
                              https://www.boost.org/doc/libs/release/libs/regex/doc/html/boost_regex/syntax/character_classes.html
                              

                              The project source code on github for the current version (2.08) shows it using Boost 1.76.0.0.

                              I have not tried any form of “proof of Boostness” as I typically use grepWin for searches similar to: “Which files in this project reference a particular manifest constant?” or “Have I defined this word in another text file in this folder tree?”

                              It does offer a replace function, which works well with plain text replacements. I have only tried regex replacements a couple of times (it worked fine). By default, grepWin saves a copy of the original file with a .bak extension added for both replacement styles.

                              Alan KilbornA 1 Reply Last reply Reply Quote 3
                              • Alan KilbornA
                                Alan Kilborn @artie-finkelstein
                                last edited by

                                @artie-finkelstein said in Suggestion: Find in Files from command line:

                                to many people RE is RE, right up until they get bitten by the flavor differences.

                                You said that very well. :-)

                                grepWin uses the boost regex engine to do its work, with the Perl Regular Expression Syntax

                                I’m not really sure what that means (the last part).
                                I’ve also seen other related references calling it PCRE (Perl Compatible Regular Expression) syntax.
                                To me, it’s “Boost RE syntax”.

                                artie-finkelsteinA 1 Reply Last reply Reply Quote 0
                                • artie-finkelsteinA
                                  artie-finkelstein @Alan Kilborn
                                  last edited by

                                  @Alan-Kilborn
                                  Nolo contendere.

                                  I think my opening statement (BTW: I thought you’d like it) also covers the authors conflation of different RE namings.

                                  1 Reply Last reply Reply Quote 0
                                  • Nick KnightN
                                    Nick Knight
                                    last edited by

                                    Coming in late, but I was searching for a way to do something similar “from the command line”.

                                    I have a utility that greps through DB-based data. It lists hits, and if a user chooses one, write the corresponding content to a temp file and opens it up in Notepad++. However, to FIND data from that point, the use has to open the find dialog and type in the text again and press go.

                                    I’d love to find a way to pre-search, JUST the file opened from the command line, for a specific text string. Have the matching strings already found, highlighted and the cursor on the first match.

                                    1 Reply Last reply Reply Quote 0
                                    • Catrin BrooksC
                                      Catrin Brooks
                                      last edited by

                                      Filelocator Lite, which is now known as AgentRansack, is what I’m using. Npp is great, however there is a flaw that can force me to delete it.

                                      1 Reply Last reply Reply Quote -1
                                      • WinterSilenceW
                                        WinterSilence
                                        last edited by

                                        you can do it without notepad https://stackoverflow.com/a/20999154/12517370

                                        1 Reply Last reply Reply Quote 1
                                        • Victorel PetrovichV
                                          Victorel Petrovich
                                          last edited by

                                          I’d like to use such a feature so that I can integrate with a browser extension that can ask Notepad++ to open the given html file (at rightclick or icon in toolbar) and edit it.
                                          Having the feature discussed here would allow me to first select a piece of text, then have Notepad open the html exactly where that is.

                                          PeterJonesP 1 Reply Last reply Reply Quote 0
                                          • PeterJonesP
                                            PeterJones @Victorel Petrovich
                                            last edited by PeterJones

                                            @Victorel-Petrovich ,

                                            If your browser extension knows the line number of the selected text, then you could use the -n command line option to tell Notepad++ which line to scroll to. You don’t need to be able to “find in files” from the command line to implement that behavior.

                                            —
                                            update: @artie-finkelstein actually pointed out -n in September 2021, though you may not have waded through enough of the posts to notice it, nor maybe understood the implication that it could solve your problem easier than “find-in-files-from-command-line”.

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