In vim, if I am in search mode by pressing /
, I can press Ctrl
+p
to find my last searched string, and press that combination again to find an even earlier searched string, and so on. I can do the same on commandline in emacs mode.
I want to do the same with less
command (i.e., press /
, and then press Ctrl
+p
to find what I searched for previously, and then press Enter
to search that term again. Can I do that? How can I do that?
Edit: reworded to make the question clearer.
To browse less
search history (~/.lesshst
by default, man less
for more):
less
a file, for example less ~/.lesshst
Use /
to search forward.
Use ?
to search backward.
Use n
for the next occurrence of the search item and N
for prior occurrence. This works for both forward and backward searches.
And as pointed out in the comments if less history is enabled you can carry your search item across invocations of less.
man less
and man lesskey
for the details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With