walles / moar

Moar is a pager. It's designed to just do the right thing without any configuration.
Other
674 stars 19 forks source link

Is it possible to set a mark and jump to it later like in `less`? #175

Closed your-diary closed 10 months ago

your-diary commented 11 months ago

In less (and vim), a mark can be set on the current line and you can jump to it later.

  1. Set a mark via 'a (a single quote followed by any single character).

  2. Jump to it via ma (an em followed by the mark character).

It seems this doesn't work in moar.


By the way, I created this issue as README.md says

If you come from Less and find Moar confusing or hard to migrate to, please report it!

walles commented 10 months ago

Thanks for reporting this!

Short answer: not right now

In what situations do you use marks? I never did so I'm trying to understand how one might want to use them.

your-diary commented 10 months ago

Marks can be used for any purposes when you want to mark a line and jump to it later.

One example is that you execute PAGER=less man xyz when you trying to learn xyz command for the first time. You may want to first read through the entire documentation while setting marks and temporarily skip too detailed sections. After you hit the end of the document, you now have shallow but wide understanding for the command, so it's time to jump back to the skipped detailed sections. Using marks, you don't have to memorize which sections you have skipped; you just type ma, mb, etc.

Another example is when you code review a pull request via git log -p develop..HEAD --reverse. This command lists the commits with their diffs in the current branch in the oldest to the newest order. In other words, you can first see the oldest commit and scroll down to see newer commits. Similar to the former example, you may sometimes want to temporarily skip a large commit or a single file in a commit. You can then just set a mark to it and jump to it later.

These examples are actually derived from my daily use-cases. In particular, I code review PRs almost everyday while setting marks. This is the only blocker functionality which prevents me from migrating to moar.

Further reading: vim how do you use marks - Google Search

postsolar commented 10 months ago

I second marks for browsing man pages. Often, different sections would cross-reference each other, so each time I want to temporarily open another section I would need to perform a lot of scrolling and/or searching to get back where I was.

walles commented 10 months ago

I just tried this with less, and it's m to set marks and ' to visit them.

walles commented 10 months ago

This is out now, please try it! https://github.com/walles/moar/releases/tag/v1.22.0

Since I'm not using this myself I'd very much appreciate feedback, good or bad.

Right now in the go-to-mark prompt I'm listing the marks in alphabetic order, maybe this should be in line number order instead? Or would that be confusing? Patches / opinions welcome.

your-diary commented 10 months ago

@walles Thank you very much! It works well.

Right now in the go-to-mark prompt I'm listing the marks in alphabetic order, maybe this should be in line number order instead? Or would that be confusing?

I have no opinion about that because I don't look at the prompt after pressing '. (Normally I memorize which marks I have set.) At least, the current display is NOT confusing or annoying. I like it.

postsolar commented 10 months ago

@walles Thank you for adding this feature, it works well, apparently even with non-ASCII characters. Personally I don't have a preference for the order of marks in the marks prompt.