svent / sift

A fast and powerful alternative to grep
https://sift-tool.org
GNU General Public License v3.0
1.6k stars 108 forks source link

Shorter results with matches found inside long lines #90

Open indeed-a-genius opened 7 years ago

indeed-a-genius commented 7 years ago

I'd like an option to limit the NUM of characters surrounding the match in the results.

For example, currently when I'm searching for "123" inside a file:

qwerty qwertyqwerty qwerty qwertyqwerty qwertyqwertyqwerty 123 qwerty qwerty qwertyqwerty qwerty

the result always displays the whole line from the beginning to the end, making the result long. qwerty qwertyqwerty qwerty qwertyqwerty qwertyqwertyqwerty 123 qwerty qwerty qwertyqwerty qwerty

With the option, if I set let's say context-chars=10 I'd like to get: rtyqwerty 123 qwerty qw

The option --output-limit doesn't help because it doesn't take the match's position into the account

svent commented 7 years ago

Thanks for the suggestion - I had the same problem in the past and will look into it.

I am currently thinking about an option like --output-context that would be similar to --output-limit but work like you suggested.