-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
Vim: visual block 'o' behaves incorrectly with up/down motions #27385
Comments
Can reproduce. This might be just an acceptable consequence of doing visual mode a little differently in zed (e.g. multi-cursor mode for visual block mode), but there is at least some inconsistency to note here. Say you create a multi-cursor context using Alt-click like so: ![]() And then you hit "v" and select a block: ![]() And then you hit "o", followed by "k" to go up a line. The result is that zed essentially takes you to regular visual mode: ![]() Whereas following the steps from @qgates - e.g. ![]() It seems as if this is because the "anchor" cursor is at the top-left in the alt-click case, but on the bottom left in the control-v case. Neither is exactly how native vim's visual block mode would behave, but the alt-click case does seem a bit more intuitive at least. |
This is partially a result of a bug in how visual block mode draws its square when "reversed" - e.g. when the cursor is at the beginning of its selection. #27604 addresses that first. Then will look at addressing the |
We've now more fully addressed this bug in #27678 |
Closes #27385 Builds on #27604 so that `vim::OtherEnd` works in visual block mode. This is accomplished by reversing the order of active selections in the buffer when the user hit `o`, so that the cursor moves diagonally across the selection. The current behavior is preserved for `shift-o`, which is how the cursors behave in vim. We'll close #27604 since this encapsulates that change, but if you'd prefer to take only the visual block motion component, we'll keep the branch for #27604 open. Test case: growing a box down and to the right, other ending, followed by growing and shrinking the box: https://github.com/user-attachments/assets/1df544e1-efce-4354-b354-bbfec007a7df Test case: growing a box up and to the left, other ending, followed by growing and shrinking the box: https://github.com/user-attachments/assets/2f6d7729-c63a-4486-960b-23474c2e507a Release Notes: - Improved visual block mode when cursor is at beginning of selection - Improved visual block mode so that `o` and `shift-o` reach parity with vim --------- Co-authored-by: KyleBarton <kjbarton4@gmail.com>
Summary
Visual block mode doesn't behave as vim when using 'o' (move cursor to [o]ther end). Vim moves the cursor to the beginning of the selection allowing use of up/down motions to vertically expand/contract the block selection.
Steps to trigger the problem:
Actual Behavior:
Due to zed's multicursor implementation, behaviour isn't as expected, jk resets the block to the RHS column and grows/shrinks the column.
Expected Behavior:
As vim, jk should make the block selection grow/shrink at the top edge.
Zed Version and System Specs
Zed: v0.178.5 (Zed)
OS: Windows 10.0.19045
Memory: 31.8 GiB
Architecture: x86_64
The text was updated successfully, but these errors were encountered: