Skip to content

Conversation

@x4132
Copy link
Contributor

@x4132 x4132 commented May 8, 2025

Adds the "g M" vim motion to go to the middle of the line.

Release notes:

  • vim: Added support for gM to go to the middle of a line

@cla-bot
Copy link

cla-bot bot commented May 8, 2025

We require contributors to sign our Contributor License Agreement, and we don't have @x4132 on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'.

@x4132
Copy link
Contributor Author

x4132 commented May 8, 2025

@cla-bot check

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label May 8, 2025
@cla-bot
Copy link

cla-bot bot commented May 8, 2025

The cla-bot has been summoned, and re-checked this pull request!

@maxdeviant maxdeviant changed the title add the vim mode g M motion to to go to the middle of a line vim: Add g M motion to go to the middle of a line May 8, 2025
@ConradIrwin
Copy link
Member

ConradIrwin commented May 8, 2025

Thanks for this! Could you also please add a test.

You should be able to copy one of the existing ones that use NeovimBackedTestContext. When you run it with cargo test -p vim --features neovim -- my_test_name it'll generate a JSON file that you need to commit too.

@x4132
Copy link
Contributor Author

x4132 commented May 8, 2025

For some reason the deletion behavior doesn't seem to be the same as neovim, even though cursor movement is the same.

# initial state:
ˇthe quick brown fox
jumped over the lazy dog
# keystrokes:
d v g M
# currently expected:
ˇbrown fox
jumped over the lazy dog
# neovim (NORMAL):
ˇbrown fox
jumped over the lazy dog
# zed (NORMAL):
ˇ brown fox
jumped over the lazy dog

* Inclusive -> Exclusive motion
* Handle 1gM correctly
* M -> shift-m
@zed-industries-bot
Copy link

Warnings
⚠️

This PR is missing release notes.

Please add a "Release Notes" section that describes the change:

Release Notes:

- Added/Fixed/Improved ...

If your change is not user-facing, you can use "N/A" for the entry:

Release Notes:

- N/A

Generated by 🚫 dangerJS against f75dbf3

@ConradIrwin
Copy link
Member

@x4132 Although it's not clear in the vim docs, gM is an exclusive motion. Updating that match statement fixed the tests you added :D.

@ConradIrwin ConradIrwin enabled auto-merge (squash) May 16, 2025 21:10
@ConradIrwin ConradIrwin merged commit d791c6c into zed-industries:main May 16, 2025
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants