Skip to content

vim: Apply strict paragraph motion only in vim mode#48024

Merged
dinocosta merged 2 commits intozed-industries:mainfrom
lex00:fix/vim-paragraph-motion-vim-only
Feb 17, 2026
Merged

vim: Apply strict paragraph motion only in vim mode#48024
dinocosta merged 2 commits intozed-industries:mainfrom
lex00:fix/vim-paragraph-motion-vim-only

Conversation

@lex00
Copy link
Contributor

@lex00 lex00 commented Jan 30, 2026

Summary

  • Addresses feedback from vim: Ensure paragraph motions use empty and not blank lines #47734 by @aviatesk
  • Reverts editor's paragraph functions to use is_line_blank() (whitespace lines count as paragraph boundaries for non-vim users)
  • Adds vim-specific paragraph_backwards/paragraph_forwards that use line_len() == 0 (only truly empty lines are boundaries per vim's :help paragraph)

This preserves vim compatibility while avoiding regression for non-vim users.

Test plan

  • cargo test -p vim -p editor passes (463 tests)
  • cargo clippy -p vim -p editor passes
  • Manual: verify {/} in vim mode skips whitespace-only lines
  • Manual: verify editor paragraph navigation stops at whitespace-only lines

🤖 Generated with Claude Code

Release Notes:

  • Fixed regression in editor paragraph navigation to treat whitespace-only lines as paragraph boundaries again

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Jan 30, 2026
@aviatesk
Copy link
Contributor

aviatesk commented Feb 4, 2026

Friendly ping.

@lex00
Copy link
Contributor Author

lex00 commented Feb 4, 2026

Screen.Recording.2026-02-04.at.11.55.48.AM.mov

This screen cap starts in regular mode and demonstrates the ^+down and ^+up work normally

It then switches to vim mode and shows { and } skipping the appropriate lines

@lex00 lex00 force-pushed the fix/vim-paragraph-motion-vim-only branch from d6a53bb to ca5d735 Compare February 4, 2026 18:59
Addresses feedback from zed-industries#47734: the previous change affected all users,
but the stricter "empty line only" paragraph behavior (per vim's :help
paragraph) should only apply in vim mode.

- Revert editor's paragraph functions to use is_line_blank() (whitespace
  lines count as boundaries for non-vim users)
- Add vim-specific paragraph_backwards/paragraph_forwards that use
  line_len() == 0 (only truly empty lines are boundaries)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@lex00 lex00 force-pushed the fix/vim-paragraph-motion-vim-only branch from ca5d735 to 7ee39fb Compare February 13, 2026 19:32
* Rename `vim::motion::paragraph_backwards` to
  `vim::motion::start_of_paragraph` and
  `vim::motion::paragraph_forwards` to `vim::motion::end_of_paragraph`
  to align it with the action and command name
* Update the existing editor test for paragraph start and end to ensure
  that non-blank lines, i.e., lines with only whitespace characters, are
  also considered paragraph boundaries, contrary to what vim mode does
Copy link
Member

@dinocosta dinocosta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @lex00 ! I've renamed the functions and updated an existing test to ensure that we don't accidentally regress the editor's paragraph movement behavior 🙂

@dinocosta dinocosta merged commit f8f4892 into zed-industries:main Feb 17, 2026
28 checks passed
rtfeldman pushed a commit that referenced this pull request Feb 17, 2026
Reverts the editor's paragraph navigation behavior that was changed in
#47734. Whitespace-only lines are now treated as paragraph boundaries
again for non-vim mode users.

Vim mode retains its own implementation where only truly empty lines
are paragraph boundaries.

Release Notes:

- Fixed editor paragraph navigation to treat whitespace-only lines as
paragraph boundaries again

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Co-authored-by: dino <dinojoaocosta@gmail.com>
@lex00 lex00 deleted the fix/vim-paragraph-motion-vim-only branch March 1, 2026 20:21
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