bellecp / fast-p

MIT License
343 stars 26 forks source link

Is there a way to jump to the line in preview window? #18

Closed winterNebs closed 3 years ago

winterNebs commented 3 years ago

I am using this to search for text in long pdfs, so the searched term might not be visible in the preview window without scrolling a lot.

From what I can tell the preview window always starts on the first line, is there any way to have it start on the line of the first match?

Thanks

bellecp commented 3 years ago

You could tweak the grep call of the preview window to show the context around the matches instead of the whole text. For instance, in the .bashrc code, change grep -E "^|$v" -i --color=always to grep -E "$v" -i -B 3 -A 10 --color=always for 3 lines before the match and 10 lines after, see https://stackoverflow.com/a/9083/13430450.

The fact that grep -E "^|$v" -i outputs the whole text is based on https://superuser.com/a/1514824: ^| ensure that every line will be a match.

bellecp commented 3 years ago

You might prefer to use https://github.com/phiresky/ripgrep-all with the fzf integration given there.