less icon indicating copy to clipboard operation
less copied to clipboard

Better support for multiple search terms

Open didib opened this issue 3 years ago • 0 comments

Hi Mark,

First, I'd like to say thanks. I've been using less since 1993 or so, and it's definitely one of the most important tools for me, used tens or hundreds of times a day. I actually find it quite amazing that you didn't loose interest after all these years. So, Thanks!

I've been thinking about this for quite some time now, but still do not have my thoughts clear. But now had another case where I wanted this feature, so decided it's a good time to create this "issue", as github calls it.

less already supports multiple search terms indirectly, by supporting "extended regexp" and the terms split with '|'. But AFAICT based on the manpage, the support is "implicit" - if the regexp library has it, you get it. That's fine, but I want more. specifically, at least two features, but perhaps others might make sense if/when work on this is started:

  1. Highlight different terms with different colors. Not much to say about this, I think it's obvious why it might be useful, and is probably not that hard to implement, if you agree to have slightly more reg-exp-library-specific code.

  2. Have a quick and simple way to jump to the next occurrence of a specific term. I still did not manage to come up with a good UI for this, as less already uses many/most keys/shortcuts and having to type long commands won't be "quick and simple", IMO. It might even make sense to introduce a new mode for searching, in which keys change their meaning - then, it can be useful to be able to type e.g. a single number or letter - e.g. pressing '3' or 'c' will jump to the next occurrence of the third term. Using a letter will also allow naturally to press 'C' for jumping to the previous occurrence. Alternatively, perhaps some new command (instead of a mode) can tell less what term number should 'n'/'N' jump to. That's less comfortable in some cases, probably, but requires a simpler and more natural change in the code/behavior, I guess. Why would this be useful? More and more, I find myself looking at some complex log file, having information about lots of different actions/tasks/items going on, and needing to search for both item-specific data (such as its ID/Name), often more than one (think a host name, a file name, etc.), and for more general terms (such as action names/IDs). I often want to see (highlight) all of them, but jump (n/N) to occurrences of a specific item (or items) - e.g. to the next occurrence of a host or file name but not the next one of a task name.

Best regards and thanks again!

didib avatar Aug 31 '21 10:08 didib