[HN Gopher] Ripgrep 14 Released
       ___________________________________________________________________
        
       Ripgrep 14 Released
        
       Author : timf
       Score  : 116 points
       Date   : 2023-11-26 20:21 UTC (2 hours ago)
        
 (HTM) web link (github.com)
 (TXT) w3m dump (github.com)
        
       | skunkworker wrote:
       | Ripgrep is probably my favorite command line tool (which replaces
       | older solutions). It's just so quick to search a folder for a
       | specific line of text in a file.
        
         | coldtea wrote:
         | Same here... the program I use most aside from my editor.
         | 
         | In fact my current editor, VS Code, also does searching powered
         | by rg behind the scenes:                 /Applications/Visual\
         | Studio\ Code.app/Contents/Resources/app/node_modules.asar.unpac
         | ked/vscode-ripgrep/bin/rg
        
       | goalieca wrote:
       | I'm not an rg wizard by any means, but it is one of the few
       | utilities that I end up using daily for one reason or another.
        
       | dharmab wrote:
       | Ripgrep is an essential tool for navigating unfamiliar codebases.
       | I also use it to quickly search many repositories for specific
       | symbols when I research the consumers of libraries and APIs.
        
       | ashton314 wrote:
       | If you are an Emacs user like me, you _must_ try out the consult-
       | ripgrep command from the peerless Consult [1] package by Daniel
       | Mendler: search your whole project with ripgrep and get a live
       | preview of every matching candidate all inside of Emacs!
       | 
       | [1]: https://github.com/minad/consult
        
         | Barrin92 wrote:
         | am a big fan of the whole consult/vertico/embark stack of emacs
         | plugins. They're fantastic.
        
         | oakpond wrote:
         | En garde! If you're a Vim user, fzf.vim [1] can do this. :)
         | 
         | [1]: https://github.com/junegunn/fzf.vim
        
           | bombela wrote:
           | And if you want interactive support, try
           | https://github.com/bombela/fzf.vim.rgfd
           | 
           | (shameless plug)
        
           | nerdponx wrote:
           | If you don't need live updating output, you can just set
           | grepprg and get results in the quickfix list with :grep[!]
           | (or the location list with :lgrep[!]).                 if
           | executable('rg')         let &grepprg = 'rg --vimgrep $*'
           | endif
           | 
           | No need for Fzf/Telescope/Denite/DDU or anything else in that
           | case.
           | 
           | See:
           | 
           | https://neovim.io/doc/user/quickfix.html#%3Agrep
           | 
           | https://neovim.io/doc/user/options.html#'grepprg'
        
             | a-dub wrote:
             | used to do that with glimpse when i worked with very large
             | codebases 23 years ago!
             | 
             | big fan of ag, ripgrep and burntsushi's rust work!
        
         | TacticalCoder wrote:
         | And for those who are also on Emacs but on the
         | Swiper/avy/ivy/counsel side of the fence, there's _counsel-rg_.
         | 
         | I use it since before _burntsushi_ (who 's here on HN btw)'s
         | ripgrep was shipped with Debian stable!
         | 
         | > search your whole project with ripgrep and get a live preview
         | of every matching candidate all inside of Emacs
         | 
         | I'm sometimes searching not just my project but my entire user
         | dir or my entire shared drive, from Emacs. A NVMe PCIe 4.0 SSD
         | (I'm using a WD SN850X which someone here recommended to me
         | when I assembled my PC) is _that_ fast and _ripgrep_ too.
        
       | tgv wrote:
       | What's the improvement this time? Translate DFAs to microcode?
        
         | burntsushi wrote:
         | https://blog.burntsushi.net/regex-internals/
        
       | grudg3 wrote:
       | rg is great, I use it a lot. Recently I have also used
       | [ambr](https://github.com/dalance/amber) which can do both search
       | (ambs) and replace (ambr) recursively in your codebase. The only
       | problem as of yet is that it does not support globbing so I
       | cannot filter on certain filetypes only.
        
         | coldtea wrote:
         | You could use "find" (or even better, "fd") to find specific
         | filetypes, then pass it to amber via xargs or some similar way.
        
         | mirashii wrote:
         | I'll throw in sd as a nice sed/find-and-replace tool. Using fd
         | + xargs + sd is a pretty good workflow if a shell glob isn't
         | good enough to target the files you want.
         | https://github.com/chmln/sd
        
           | cstrahan wrote:
           | I'll also throw in Leah Neukirche 's xe as a better
           | alternative to xargs: https://github.com/leahneukirchen/xe
        
           | ForkMeOnTinder wrote:
           | I wanted to like sd but it doesn't support my main use case
           | of recursive search/replace. Imagine every time you wanted to
           | grep some files you had to build a find+xargs+rg pipeline...
           | it just takes me out of the flow too much. I'm glad people
           | are posting other options here, I'm looking forward to trying
           | them.
           | 
           | https://github.com/chmln/sd/issues/62
        
         | nicoburns wrote:
         | https://github.com/facebookincubator/fastmod is also great for
         | the replace usecase.
        
       | coldtea wrote:
       | I don't seem to get the hyperlinks with either Terminal or iTerm.
       | 
       | P.S. OK found it: it can't show hyperlinks when you explicitly
       | pass a file name to search (for internal implementation reasons,
       | might be fixed later). It works when you search in directories
       | etc.
        
       | lelandbatey wrote:
       | The notes state that the headline feature is "hyperlink support".
       | However, the notes don't seem to really explain what that means.
       | Can someone explain a bit more about what that feature does/is?
       | What's a use case?
        
         | burntsushi wrote:
         | It creates links in the output. You click them. It opens the
         | file. That's pretty much it.
        
         | kzrdude wrote:
         | Terminals (some terminals) support hyperlinks and it creates
         | clickable links. For example ls -l --hyperlink=auto If you
         | terminal supports it, you can click the names.
         | 
         | See here for more info:
         | https://github.com/Alhadis/OSC8-Adoption/
        
         | coldtea wrote:
         | So, when you search for "foo" in mydir/, rg can find the term
         | foo inside different places in a number of files, and then
         | print the results like:                 mydir/myfile.java
         | 15: return foo;       78: System.out.println(foo);       123:
         | // TODO: change foo to bar
         | 
         | Hyperlink support means that the line numbers (15, 78, 123) are
         | clickable, and will open your favorite editor to that file and
         | that line number.
         | 
         | That's if your terminal supports hyperlinks, or has hyperlink
         | support enabled - most do. Depending on the terminal app it
         | might be control/cmd click, or option-click to open the
         | hyperlink.
         | 
         | Note (this got me while trying): hyperlinks are not emitted
         | when you search inside a specific file directly, e.g. "rg foo
         | myfile.py".
        
           | lelandbatey wrote:
           | I'm fascinated! I've been living with and authoring CLI tools
           | for about a decade now and I didn't know that there's
           | widespread support for additional attributes on text besides
           | styling (color, italics, underline, etc) in common terminal
           | emulators. What a cool thing!
        
           | burntsushi wrote:
           | For the single file case, if you pass --with-filename then it
           | should work.
        
         | citruscomputing wrote:
         | Sibling comments have explained, but the keyword to search to
         | learn more is "OSC-8 hyperlinks"
        
       | andrewstuart wrote:
       | I wish Jetbrains would integrate ripgrep into Pycharm as a native
       | feature.
        
       | leonheld wrote:
       | I'm very thankful for ripgrep, ag and fzf.
        
       | piinbinary wrote:
       | I'm still sad that --sort-files makes ripgrep run in single-core
       | mode. (I know you can't make --sort-files _free_ in multi-core
       | mode, but it would still be faster than single-core)
       | 
       | https://github.com/BurntSushi/ripgrep/issues/152
        
       | forgotusername6 wrote:
       | The release notes use the word "headling" twice instead of
       | presumably "headline". I had to look it up in case this was a new
       | usage of this archaic word.
        
         | burntsushi wrote:
         | Ah nice catch! I actually meant to say "headlining."
        
       ___________________________________________________________________
       (page generated 2023-11-26 23:00 UTC)