Genivia / ugrep

NEW ugrep 6.5: a more powerful, ultra fast, user-friendly, compatible grep. Includes a TUI, Google-like Boolean search with AND/OR/NOT, fuzzy search, hexdumps, searches (nested) archives (zip, 7z, tar, pax, cpio), compressed files (gz, Z, bz2, lzma, xz, lz4, zstd, brotli), pdfs, docs, and more
https://ugrep.com
BSD 3-Clause "New" or "Revised" License
2.57k stars 109 forks source link

Feature idea: Jump to line #296

Closed leahneukirchen closed 11 months ago

leahneukirchen commented 11 months ago

From the interactive mode, ^Y opens the file in a pager or an editor, however you lose track of the search result.

Most Unix pagers and Editors (less, vim, emacs...) support being called like program +NNN file to jump to line NNN, this would simplify use a lot.

genivia-inc commented 11 months ago

That's a great idea.

It is not that simple to implement though, because the TUI has no concept of line numbers of the matches. A simple implementation can take the line number shown on the screen if -n is active. This is the only clue we can use. It won't work if -n is not active, or if -l or -c are active.

leahneukirchen commented 11 months ago

If it only works with -n, that's good enough for me.

genivia-inc commented 11 months ago

I've implemented this feature in my dev version. Some pagers do not support +linenum such as moar see #286 where I added a comment about this.

So we have two choices:

  1. always add +linenum regardless of the pager specified, but this may not start the pager if the pager like moar returns an error.
  2. only add +linenum when the pagers are more or less or vi or vim or emacs

I prefer 2 which is safe, so I'll include this in the next release.

leahneukirchen commented 11 months ago

More tools that do it: most, w3m, pico, nano, joe, zile, vile, mg, mcedit, vis, kak... :)

genivia-inc commented 11 months ago

OK, ok... got it!

walles commented 11 months ago

More tools that do it: most, w3m, pico, nano, joe, zile, vile, mg, mcedit, vis, kak... :)

Out of curiosity @leahneukirchen, how did you come up with that list?

leahneukirchen commented 11 months ago

My thinking of every editor I had here and trying. ;)

Notably, helix doesn't support it (but I'll file a bug).

genivia-inc commented 11 months ago

Implemented in ugrep v4.2 (released).