Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to search from current line like vim or less ? #257

Closed
mingwiki opened this issue Nov 22, 2024 · 2 comments
Closed

How to search from current line like vim or less ? #257

mingwiki opened this issue Nov 22, 2024 · 2 comments

Comments

@mingwiki
Copy link

if type "/something", will always search from beginning. it's not same like vim or less.

for example, I use moar to view my logs. I'd like to search by date first, and search something from the date, moar will always search from the top, not works like vim.

@mingwiki
Copy link
Author

i'd like to search the next one by /something, and previous one by ?something like vim

walles added a commit that referenced this issue Nov 26, 2024
Just like in less.

Fixes #257.

As a side effect, this changes the "show help" key from '?' to 'h',
since '?' is now used for searching backwards.

Also, we used to have 'h' and 'l' for left and right for vim
compatibility, but since less compatibility is more important than vim
compatibility, they were removed.

So this change also unfixes #25.
@walles walles closed this as completed in 8c6f666 Nov 26, 2024
walles added a commit that referenced this issue Nov 26, 2024
When searching in the pager, pressing ESC will now skip back to where
the search started. This is useful when you want to quickly jump back to
where you started searching from.

Pressing RETURN will still stop the search and leave the cursor where it
is.

Being able to press ESC to go back somewhat improves on the first half
of #257, related to searching from
the current position to the end.
@walles
Copy link
Owner

walles commented Nov 26, 2024

if type "/something", will always search from beginning. it's not same like vim or less.

Not exactly.

moar will search from the current location.

But if there are no hits below the current location, moar will (just like VSCode or Firefox) wrap and search the remaining part of the file as well.

for example, I use moar to view my logs. I'd like to search by date first, and search something from the date, moar will always search from the top, not works like vim.

With 02a6f11, ESC while searching will take you back to where the search started. RETURN will stop searching but remain in place.

Not exactly what you asked for, but if moar finds something in the wrong part of the file, you can now ESC your way back.

Or since moar does regex, you could search for 2024-05-06.*monkeys to find all monkeys that day.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants