support for motion to last occurrence of character on line (e.g. d + last f<char>) #30548
ohmsl
started this conversation in
Ideas From Vim
Replies: 1 comment 2 replies
-
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Context
In classic Vim, motions like
f<char>,F<char>,t<char>, andT<char>let you jump to the first occurrence of a character in either direction. However, there's no built-in motion for jumping to the last occurrence of a character on the current line.This comes up often in practice, especially when working with code or structured text, where jumping to the last
),;,,,&, etc. on a line is more useful than the first.Zed's Vim mode currently mirrors standard Vim behaviour for these motions, but does not offer a way to move to or operate on the last occurrence of a character.
Proposal
Add a motion that jumps to the last instance of a character on the current line. Ideally, this would work with operator-pending commands like
d,c,y, etc.Example use cases:
d+ motion to delete up to the last),;,&, etc.,on a linec+ motion to change everything up to the final quote, etc.Suggested additions
New motions that could be implemented:
PushFindLastForward– jump forward to the last match of a character on the current linePushFindLastBackward– jump backward to the last match in reverse;and,These should be composable and behave like other Vim motions in Zed (e.g.
f,t, etc.).My idea of the requirements:
vim::subsystemf/Fd,c,y, etc.Let me know if this is something worth upstreaming, or if there's an existing mechanism I’ve missed.
Would appreciate thoughts from other vim mode users too.
Beta Was this translation helpful? Give feedback.
All reactions