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

Marks support #190

Open
vaygr opened this issue Jul 22, 2023 · 2 comments
Open

Marks support #190

vaygr opened this issue Jul 22, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@vaygr
Copy link

vaygr commented Jul 22, 2023

Is your feature request related to a problem? Please describe.

It would be great to minimally support marks as in vi/vim/vile.

Describe the solution you'd like

Use-cases could be:

  • mx - set mark x
  • 'x - jump to mark x
  • d'x - delete text from current cursor position up until the line marked by mark x
  • d`x - delete text from current cursor position up until the position marked by mark x
  • >'x - increase indent for the block of text from current cursor position up until the line marked by mark x
  • <'x - decrease indent for the block of text from current cursor position up until the line marked by mark x
  • c'x - change text from current line to line of mark x
  • y`x - yank text to unnamed buffer from cursor to position of mark x

Note: note the difference between using commands with ' and `.

Describe alternatives you've considered

Visual mode can replace this to some extent, but marks are quicker and more convenient.

Additional context

N/A

@vaygr vaygr added enhancement New feature or request needs-triage Waiting for someone to triage labels Jul 22, 2023
@wedaly wedaly removed the needs-triage Waiting for someone to triage label Jul 24, 2023
@wedaly
Copy link
Contributor

wedaly commented Jul 24, 2023

Looked through the vim documentation for marks: https://vimhelp.org/motion.txt.html#mark

A few thoughts on the implementation:

  1. Uppercase marks (A-Z) are valid across files, but aretext doesn't currently store any state. So it probably makes sense to support only lowercase marks (a-z) that are valid within the current file.
  2. I think mark positions would need to adjust on each insertion/deletion. Insertions/deletions before the mark should move the mark position, and deletions at the mark position should remove the mark (I think).
  3. Need to think about prev/next documents. If I set a mark in file A, then open file B, then go back to file A, the mark should be preserved (think that's vim's behavior). I wonder where that state should be stored? In file.TimelineState maybe?
  4. What happens if the document gets reloaded? Aretext uses a text alignment algorithm to match lines in the current document (in-memory) with lines in the updated document (from disk). Maybe that could be used to adjust the mark locations on reload.
  5. Vim has an ex command :marks that shows all marks that have been set. Maybe the equivalent in aretext would be a searchable menu, like the find and open command?

@vaygr
Copy link
Author

vaygr commented Jul 24, 2023

@wedaly,

  1. Makes sense to me.
  2. Maybe. In vile deletion at the mark position moves the mark to the next character.
  3. Yes, in vile marks are per document. So even if you have 2 separate windows with the same document, marks would be the same.
  4. Good question. If the document was changed outside of aretext, maybe it's better to drop marks altogether to avoid unexpected results.
  5. This is a great idea.

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

No branches or pull requests

2 participants