Skip to content

vi-like normal mode: support Jumps #1101

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

Closed
3 tasks
christianparpart opened this issue May 23, 2023 · 0 comments · Fixed by #1646
Closed
3 tasks

vi-like normal mode: support Jumps #1101

christianparpart opened this issue May 23, 2023 · 0 comments · Fixed by #1646
Assignees
Labels
enhancement New feature or request vi-mode Vi/Vim movement and operation mode
Milestone

Comments

@christianparpart
Copy link
Member

when pressing % to jump to a matching symbol and land somewhere completely unexpected (or do any other kind of long distance movement), you may want to quickly jump back.

For that, adding support for jumps is more useful than hard to implement.

  • '' `` (To the position before the latest jump, or where the last "m'" or "m`" command was given.)
  • <Ctrl>+O
  • <Ctrl>+I

To quote vim doc

A "jump" is a command that normally moves the cursor several lines away.  If
you make the cursor "jump" the position of the cursor before the jump is
remembered.  You can return to that position with the "''" and "``" commands,
unless the line containing that position was changed or deleted.  The
following commands are "jump" commands: "'", "`", "G", "/", "?", "n", "N",
"%", "(", ")", "[[", "]]", "{", "}", ":s", ":tag", "L", "M", "H" and the
commands that start editing a new file.
Jumps are remembered in a jump list.  With the CTRL-O and CTRL-I command you
can go to cursor positions before older jumps, and back again.  Thus you can
move up and down the list.  There is a separate jump list for each window.
The maximum number of entries is fixed at 100.

There's more interesting stuff that might be worth adding, see :help mark-motions in vim.

Applying this to a terminal

I think most important is to add some sort of jump list (maybe start capping it to 100, just like in vim) and then make sure that certain jumps are recorded into that jump list.

An item in a jump list would probably be simply a CellLocation. This means, line values are relative. negative points into the history. This also means, that when adding new lines, each recorded line location would needed to be adjusted accordingly. I wonder if that one could be optimized (or if that doesn't matter at all, perf wise).

The jump list should probably be remembered per screen buffer, because each screen buffer might most likely have different history line counts. Most likely, jump list only make sense when having a history at all.

@christianparpart christianparpart added enhancement New feature or request vi-mode Vi/Vim movement and operation mode labels May 23, 2023
@christianparpart christianparpart added this to the 2023-1 milestone Oct 15, 2023
@christianparpart christianparpart modified the milestones: 2023-1, 2024-1 Jan 1, 2024
@Yaraslaut Yaraslaut self-assigned this Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request vi-mode Vi/Vim movement and operation mode
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants