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

VimFx Jump list – like '' but more than one step, and in both directions #814

Closed
letientai299 opened this issue Sep 27, 2016 · 35 comments
Closed
Labels

Comments

@letientai299
Copy link

letientai299 commented Sep 27, 2016

Edit by @lydell:

Store all locations that are saved in the ' mark as a list, and provide one command for going backwards in that list, and one for going forward. (The list is per tab.)

Original description:

Please consider adding jump list to VimFx.

I find myself rarely use Ctrl-O (open file) and Ctrl-I (Show Page Info) on Firefox. So, I won't be sad if the 2 shortcuts can be used to make Firefox be more like Vim. Perhaps other people find this feature useful too.

@lydell lydell closed this as completed Sep 27, 2016
@letientai299
Copy link
Author

Please let me know the reason for closing this issue so quick.
Maybe I miss some things, but I did try to search for closed issues and available shortcuts before open this issue.

@lydell
Copy link
Collaborator

lydell commented Sep 27, 2016

You didn't give a detailed use case example. You didn't even say what you want/need. Saying "do Vim jump list but for a web browser" is not helpful.

@letientai299
Copy link
Author

Thank you. I'll try to explain my request in detail.

Summary

Make Ctrl-O navigate back to last browsing location, in the current tab or other tabs. And make Ctrl-I navigate back to previous browsing location (the previous location is available only after we had used Ctrl-O).

Usage Example

While reading a very long website, I see some new terms that they say "will be
explained later". But I want to understand them right now. So I use / to search for the terms and n to go to its explaination. Once satisfy with that, I of course want to go back to last reading location. But, damn it, I forgot to mark the location before jump around.

Really wish Ctrl-O can bring me back, like how vim does. But, it open Open File dialog 😞

Why current features is not enough:

  • gl only allow us switching back and forth between tabs. It cannot be used to switching between locations in the same tab.
  • m and ' require us to manually mark the location.
  • I'm not familiar with JavaScript enough to write a custom function/mapping for such use case.

P/s: Forgive my broken English. I really love VimFx. This addon only is enough for me to not switching to Chrome. If I know JavaScript better, instead of an issue, I would make a Pull Request. Perhaps today is a bad day for you. Or you have tired to looking into bad formatting/explaining issue. Anyway, I wish you and VimFx the bests. :)

@lydell
Copy link
Collaborator

lydell commented Sep 27, 2016

Thanks for your detailed response! The hardest thing about new features is always understanding who they should work, and what the user actually needs.

P/s: Forgive my broken English.

Don't worry, your English is really good!

This addon only is enough for me to not switching to Chrome.

Just in case you don't know, there is a similar add-on for Chrome called Vimium (which VimFx is heavily inspired by).

' require us to manually mark the location.

Well, '' takes you to the last scroll position automatically. But if you've searched for something and then pressed n a few times, it will only take you one n back, so I guess it won't help much for you.

browsing location

Let's define a "browsing location". Is that the same thing that sets the ' mark, perhaps?


This is an idea I have:

We'll have a list like this:

previous : List Location
current : Location
next : List Location

Going back means moving current into next and moving one of the locations in previous to current. Vice versa for moving forward.

When adding a new Location, current is added to previous and next is discarded and replaced with the new Location.

But what happens to the list when you click a link?


This is a question I stumbled upon: Is it really necessary to have a global jump list (across tabs, but perhaps one per window), rather than one per tab? Because one per tab is much easier to understand, but perhaps I'm missing a use case.

@letientai299
Copy link
Author

Just in case you don't know, there is a similar add-on for Chrome called Vimium (which VimFx is heavily inspired by).

I tried a few vim motions addon on both Chrome and Firefox. Chrome doesn't allow addon run on some website (for example: Chrome Web Store, chrome://* sites). Firefox does. And VimFx is far more polish than Vimium. 😄


Is it really necessary to have a global jump list (across tabs, but perhaps one per window), rather than one per tab? Because one per tab is much easier to understand, but perhaps I'm missing a use case.

Indeed a good point. I prefer to have one list per window, as it's too easy to move around without set a mark to back.

The hardest case is when user change the tab content (by open link in current tab or close it). For that case, I propose to clear remove the locations that associated with the changed/closed tab. User shouldn't be surprised if they cannot navigate back to somewhere in a non-existed tab. They should keep their tabs open manually.


Let's define a "browsing location". Is that the same thing that sets the ' mark, perhaps?

Basically, anything that change the display of Firefox should also save an browsing location before moving on. So, following actions should add new item to the list:

  • Navigating in one tab: n, N, m, G and gg
  • Navigating across tabs: gl, J, K, Ctrl-tab, Ctrl-Shift-tab, Ctrl+<number>...
  • Open a link in a new tab, by using the mouse or f and F.

I'm not sure what sets the ' mark. Hope that my idea useful for you.


This is an idea I have:

We'll have a list like this:

previous : List Location
current : Location
next : List Location

Going back means moving current into next and moving one of the locations in previous to current. Vice versa for moving forward.

When adding a new Location, current is added to previous and next is discarded and replaced with the new Location.

Totally agree with you. Just one minor fix is that new Location should be
assigned to current.

@lydell
Copy link
Collaborator

lydell commented Sep 27, 2016

I'm not sure what sets the ' mark. Hope that my idea useful for you.

https://github.com/akhodakivskiy/VimFx/blob/8348ae78d901b737984949aef90c1396e2ef90b3/documentation/commands.md#marks-m-and-


Could you give a nice example like in your second comment where jumping between tabs is used?

@letientai299
Copy link
Author

Ok. I've tried. But mose of the use cases could be cover by a combination of gl (or several J, K) and the location list for a single tab. And, perhaps a single location list per window is as complicated as global mark. So, I'm ok with a list per tab.

@lydell
Copy link
Collaborator

lydell commented Sep 28, 2016

Ok, I see how a jump list could be useful.

@lydell lydell reopened this Sep 28, 2016
@lydell lydell added the feature label Sep 28, 2016
@lydell lydell changed the title [Feature Request] VimFx Jump list VimFx Jump list – like '' but more than one step, and in both directions Sep 28, 2016
@lydell
Copy link
Collaborator

lydell commented Sep 29, 2016

Here's an idea I have. I don't know if it is a good one yet.

  • '- takes you backward in the jump list.
  • '+ takes you forward in the jump list.

Possibly:

  • '/ takes you to where you started your last search. This could possibly let you step through a list of locations as well. Perhaps '? for going in the other direction.
  • '# takes you backward through n/N locations, and '* for going forward.

So, the idea is to add more special marks (in addition to '), instead of adding more commands.

However, what if you want '- to happen when you press <c-o>? That wouldn't be possible. You can change the ' shortcut, and you can change the - mark, but you always end up with two key strokes. Perhaps that's not a problem. We could also easily make it possible to allow creating custom commands that go to a specific mark, but if it is a very common request to "map <c-o> to '-", then I won't work because we can't expect most users to write a config file.

@letientai299
Copy link
Author

I see that you don't want VimFx affect Firefox default shortcuts.
But the proposal for ' key is quite unintuitive for me as that not how it works in Vim.

I propose to use g[ and g] for this purpose. Still 2 key presses, but easier to grasp.
We will see if there's any one else interesting in remap them to <C-o> and <C-i>.

@lydell
Copy link
Collaborator

lydell commented Sep 29, 2016

What do you think about the proposed marks, then? Such as '/. Considering the use case example you've provided, pressing '/ seems to achieve your goal faster than pressing <c-o> (or g[ or whatever) a bunch of times.

@letientai299
Copy link
Author

For '/ and '?, what if I perform search with several different queries, and after that, need to go back to where I begin the first search?

For '# and '*, perhaps I misunderstood, but I think that is n and N's job. If I think about jump to locations of a keyword, I definitely use / and then n or N for that purpose.

@lydell
Copy link
Collaborator

lydell commented Sep 29, 2016

For '/ and '?, what if I perform search with several different queries, and after that, need to go back to where I begin the first search?

I was thinking that you could press '/ multiple times. Or use 5'/.

For '# and'*, perhaps I misunderstood, but I think that isn and N's job.

Makes sense.

@letientai299
Copy link
Author

One more thing. '/ and '? solve only on specific case (searching). The new commands could solve more use cases. For example:

  • Jump around by click into internal link in the document (footnotes, link to other sections) and then go back.
  • Read an article, get boring, Jump to bottom of page to view Disqus comments to see what people talk about it, then go back if the comments can convince me.

@lydell
Copy link
Collaborator

lydell commented Sep 29, 2016

I'm not suggesting that '/ should replace commands for going through the jump list the way you describe. I'm suggesting to add '/ in addition to that, since it seemed like a good thing considering the first use case example you provided. But perhaps we should just drop that – you don't seem to find it useful? :)

Regarding going back from internal links: I don't think that'll be possible with the jump list. Couldn't you use H and L?

@letientai299
Copy link
Author

Regarding going back from internal links: I don't think that'll be possible with the jump list. Couldn't you use H and L?

Nice catch. I forget that thing.

@lydell
Copy link
Collaborator

lydell commented Oct 1, 2016

To anyone reading this: If g[ and g] are added, does it then make sense to remove the ' mark?

@SageEx
Copy link

SageEx commented Oct 1, 2016

Hi, I see a very interesting discussion is going on.

Allow me to contribute some thoughts,

For '/ and '?, what if I perform search with several different queries, and after that, need to go back to where I begin the first search?

I was thinking that you could press '/ multiple times. Or use 5'/.

For me, remembering the last query searched is enough. Any other case arising from searching multiple queries and jumping can be handled by the jump list, the g[ and g]. The jump list also gives a time based list and hence feels more natural than say going to the third search.

To anyone reading this: If g[ and g] are added, does it then make sense to remove the ' mark?

I'd say keep it, going with the vim philosophy. The ' mark can be used to jump 'quickly' to the last location.

We will see if there's any one else interesting in remap them to <C-o> and <C-i>.

I'd definitely be interested in such a feature. Maybe, make it accessible just through the config file. But the ability to override (if desired), the <C-o> and <C-i> is very attractive.

What I would like to add, if possible is a way to visualize the marks, like something the vim :marks command. Maybe through a popover like the one which is activated by pressing the ? key.

@ropery
Copy link
Contributor

ropery commented Oct 2, 2016

Since we're discussing the jump list, here we go...
There's one thing that's sometimes bothered me about the ' mark. For instance, tap '' and we jump somewhere, then '' again, there's no response. This is not very useful at all. My expectation is for repeated '' to toggle between two positions, and I suppose that's why ' was chosen by VIM for special mark in the first place.

If g[ and g] are added, I think we can make '' more useful by making it do something different. Roughly, whatever can be done via g[/g] should not be done with ''. Since g[ and g] seem to mostly concern search jumps, I think '' should then not register a position reached by n or N. As a result, when you start searching and press a bunch of n, you can tap '' to go back to where you started searching.

As for the jump list UI... I don't think it's very feasible. Ideally, something like the gH/gX menu would be nice, but I believe these are native Firefox methods. For the jump list to come up like that, VimFx probably needs to re-invent a bunch of stuff. I don't think we jump nearly enough to warrant the hassle.

@SageEx
Copy link

SageEx commented Oct 2, 2016

There's one thing that's sometimes bothered me about the ' mark. For instance, tap '' and we jump somewhere, then '' again, there's no response. This is not very useful at all. My expectation is for repeated '' to toggle between two positions, and I suppose that's why ' was chosen by VIM for special mark in the first place.

True, ' should jump to the last marker. Repeatedly pressing it should toggle between 2 last two marks.

Since g[ and g] seem to mostly concern search jumps,

This. Is there any reason why we should have g[ and g] restricted to search jumps only ? Why not make them backward and forward mover for general jump list ?

As for the jump list UI... I don't think it's very feasible.

Oh well, if it's too much work for a little feature, we can take it up later. For now, I'd be interested in implementing the jumplist feature first.

@ropery
Copy link
Contributor

ropery commented Oct 2, 2016

Is there any reason why we should have g[ and g] restricted to search jumps only ? Why not make them backward and forward mover for general jump list ?

They should yes, otherwise we'd just use n/N.
What's not clear though is what is a jump.

@letientai299
Copy link
Author

What's not clear though is what is a jump.

@lolilolicon I copy this from Vim manual.

A jump is one of the following commands: ', ```, G, `/`, `?`, `n`,
`N`, `%`, `(`, `)`, `[[`, `]]`, `{`, `}`, `:s`, `:tag`, `L`, `M`, `H` and
the commands that start editing a new file. If you make the cursor `jump`
with one of these commands, the position of the cursor before the jump is
remembered. You can return to that position with the `''` and ```` command,
unless the line containing that position was changed or deleted.

In VimFx, we don't have cursor. But I think we could call the "view port" on web page as the cursor, and apply the definition for the command that we have in VimFx.

@SageEx
Copy link

SageEx commented Oct 2, 2016

Sounds perfect.

On Sun, Oct 2, 2016, 10:33 AM Le Tien Tai notifications@github.com wrote:

What's not clear though is what is a jump.

@lolilolicon https://github.com/lolilolicon I copy this from Vim manual.

A jump is one of the following commands: ', `, G, /, ?, n,
N, %, (, ), [[, ]], {, }, :s, :tag, L, M, H and
the commands that start editing a new file. If you make the cursor jump
with one of these commands, the position of the cursor before the jump is
remembered. You can return to that position with the '' and```` command,
unless the line containing that position was changed or deleted.

In VimFx, we don't have cursor. But I think we could call the "view port"
on web page as the cursor, and apply the definition for the command that
we have in VimFx.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#814 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AGz561kFejidnYkfWsKM9GnzbaRrpsq9ks5qvzsUgaJpZM4KHTv2
.

Arindam Banerjee

@lydell
Copy link
Collaborator

lydell commented Oct 2, 2016

I'd say keep it, going with the vim philosophy. The ' mark can be used to jump 'quickly' to the last location.

Note that VimFx is not trying to copy Vim. We’re trying to make useful and simple features inspired by whatever we come across. g[ is also 'quick', isn’t it? If not, feel free to rebind it to some other shortcut. Also, '' could be added as a custom command.

What I would like to add, if possible is a way to visualize the marks, like something the vim :marks command. Maybe through a popover like the one which is activated by pressing the ? key.

The rule in VimFx is that features are not added until the requester gives detailed use case examples and helps with designing (as in describing how it should work and/or look like) the new feature. Feel free to open a new issue about this, but my gut feeling is that this won’t happen (just like @lolilolicon was hinting at).

There's one thing that's sometimes bothered me about the ' mark. For instance, tap '' and we jump somewhere, then '' again, there's no response. This is not very useful at all. My expectation is for repeated '' to toggle between two positions, and I suppose that's why ' was chosen by VIM for special mark in the first place.

That’s a bug. Your expectations are correct.

Since g[ and g] seem to mostly concern search jumps

That’s a misunderstanding. They’re supposed to concern the same jumps as the ' mark does today.

What's not clear though is what is a jump.

Since nobody seems to have followed the link in one of my previous comments, I’ll just copy-paste the documentation here :)

“One mark is special: '. Pressing '' takes you to the scroll position before the last gg, G, 0, $, /, n, N or '.”


Here is the current plan:

  1. Remove the ' mark.
  2. Don’t add any new special marks.
  3. Maintain a jump list per tab. Any time today’s ' mark would be changed, the current location is added to the jump list.
  4. Provide g[ for going to the previous location in the jump list, and g] for going to the next. (Both commands take a count.)
  5. (If somebody really wants the ' mark back, it can easily be added as a custom command – I’ll post it in the wiki.)

This seems like a simple solution, and seems to do what is requested here. Thoughts?

@ropery
Copy link
Contributor

ropery commented Oct 2, 2016

A jump is one of the following commands: ', `, G, /, ?, n, N, %, (, ), [[, ]], {, }, :s, :tag, L, M, H

So applied to VimFx, the ones that make sense are ', G/gg/0/$, /, n/N. i.e. mostly concerning "large" scrolls, search locations, and marks, currently.
I do think gi should produce a jump too (when the view port is changed).
Perhaps VimFx will understand some other jumps in the future, more apt for web pages.

and the commands that start editing a new file.

This is overlapping with gH in VimFx. I wonder how the integration with history would go. Should the jump list work cross history? What if I navigate to a new URL in this tab and come back, does it make sense to remember jumps from "back then"? Web sites are much more complicated and dynamic than local text files, so IMO probably not.

@ropery
Copy link
Contributor

ropery commented Oct 2, 2016

@lydell Let me quote myself here,

As a result, when you start searching and press a bunch of n, you can tap '' to go back to where you started searching.

Can we have this? Seems like a useful feature and the one @letientai299 initially requested.

@lydell just so you know, I did read your link; what I meant was we seemed to be contemplating something more than those registerd by the ' mark...

@SageEx
Copy link

SageEx commented Oct 2, 2016

@lydell This sounds really good for now.
@lolilolicon Cross history jump list can be pretty useful, if the web page is not dynamic. For simple blogs, pdfs, and simple sites. I'd say jump to the scroll position regardless will be a good addition.

@ropery
Copy link
Contributor

ropery commented Oct 2, 2016

@SageEx yes they can be useful, I agree, but considering there's no support for a jump list UI or such, but only a simple step-wise back-and-forth, it's unlikely anyone will do "long jumps". We should probably just use a new tab...

@SageEx
Copy link

SageEx commented Oct 2, 2016

@lydell

g[ is also 'quick', isn’t it?

This is not the same as ' marker, since the ' toggles between the last and current position. To have the same functionality with the g[, we need to alternate between g[ and g]. Thus, it's not quick and defeats the purpose.

There are sites where we have a reference and a editor to try things out (Hackerrank comes to mind). Having the ability to jump quickly to reference the question details and jump back, with a single key - that sound's great.

@lydell
Copy link
Collaborator

lydell commented Oct 2, 2016

I do think gi should produce a jump too (when the view port is changed).

That’s a cool idea. It might be doable.

Perhaps VimFx will understand some other jumps in the future, more apt for web pages.

I don’t understand this. Are you dissatisfied with the current jumps? What are you trying to suggest here? :)

As a result, when you start searching and press a bunch of n, you can tap '' to go back to where you started searching.

Can we have this? Seems like a useful feature and the one @letientai299 initially requested.

Well, that would solve the first use case example that @letientai299 posted, but @letientai299 have not been very interested in such a feature in this thread. But perhaps it should be added, yes.

Cross history jump

As mentioned earlier in this issue, I don’t think that’s possible. The current plan is to reset the jump list when you click a link in a tab (just like the marks are).

alternat[ing] between g[ and g] … [is] not quick and defeats the purpose.

Why is that not quick, what purpose does what defeat and why? :)

Also, is this a common thing people would want, or do you think we’d be fine with a custom command?


I see two paths forward now:

  1. Stick with the plan in my last comment.
  2. Stick with the plan in my last comment, but with the following changes:
    • Keep the ' mark, and fix its bugs.
    • Add a / mark for going to the location of the last search (/, not n/N). (Pressing '/ multiple times in a row is the same as doing it only once.)

@SageEx
Copy link

SageEx commented Oct 2, 2016

@lydell The second plan seems to satisfy all the use cases.

@SageEx
Copy link

SageEx commented Oct 2, 2016

@lydell It's not quick because it's slower than pressing '' twice. No need to think about whether the previous mark was older or newer. It's just ''.

I'd say the second plan seems is best.

@ropery
Copy link
Contributor

ropery commented Oct 2, 2016

Perhaps VimFx will understand some other jumps in the future, more apt for web pages.

I don’t understand this. Are you dissatisfied with the current jumps? What are you trying to suggest here? :)

Nah, I was thinking for all the jumps supported by VIM there's only a few that currently make sense in VimFx, but web pages are actually semantically richer in some way (and a lot messier), so possibly VimFx can add a jump motion of "next section" or "next div" or "next comment" and such. In a way gi & Tab is already doing this sort of thing.

@lydell
Copy link
Collaborator

lydell commented Oct 2, 2016

@lolilolicon Ah, you’re looking for some kind of screen reader-like navigation functionality. That doesn’t belong in this issue, though.


To summarize, here’s the plan:

  • Fix the ' mark.
  • Add g[ and g]. Their jump list is per tab, reset when you click links and updated whenever the ' mark is (more or less).
  • Add the / mark.

lydell added a commit that referenced this issue Oct 2, 2016
The `'` mark is supposed to point to the location before the last
"jump." One such jump is using the `'` mark itself (by pressing `''`).
This means that running `''` several times in a row will flip back and
forth between two locations. However, that was previously broken. `''`
took you back to the last location, but then you got stuck there. This
commit fixes that bug.

Refs. #814.
@lydell lydell closed this as completed in 26f2a6b Oct 2, 2016
@SageEx
Copy link

SageEx commented Oct 2, 2016

Thanks a lot for the quick update 😃

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

No branches or pull requests

4 participants