Skip to content

Conversation

@acardonna
Copy link
Contributor

@acardonna acardonna commented Nov 1, 2025

This adds a textobjects.scm file to enable Tree-sitter-based text objects for Java. Currently, Zed only supports this functionality in Vim mode. With this addition, you'll be able to treat several Java constructs as text objects and target them with any Vim operator like d (delete), c (change) or y (copy) or select them with v, as well as navigate code semantically. Here are the details:

  • Use ic / ac to work inside or around a class, interface, enum, record and annotation
  • Use if / af to work inside or around a method, lambda and constructor
  • Use igc / agc to work inside or around a single-line comment, multi-line commentand javadoc comment
  • Use ]m / [m to go the next or previous method or constructor
  • Use ]] / [[to go the next or previous class-like construct (a class, interface, etc.).
  • Use ]/ / [/ to go to the next or previous comment.

If you are interested in knowing more about these features, you can find more information in the official Zed documentation for Tree-sitter and for Text Objects. The Default Vim Bindings file in Zed is also a good resource. There are good built-in text objects like i for indentation, b for blocks or [x / ]x for selecting greater or smaller syntax nodes.

@cla-bot
Copy link

cla-bot bot commented Nov 1, 2025

We require contributors to sign our Contributor License Agreement, and we don't have @acardonna 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'.

1 similar comment
@cla-bot
Copy link

cla-bot bot commented Nov 1, 2025

We require contributors to sign our Contributor License Agreement, and we don't have @acardonna 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'.

@cla-bot
Copy link

cla-bot bot commented Nov 1, 2025

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

@acardonna
Copy link
Contributor Author

@cla-bot check

@cla-bot cla-bot bot added the cla-signed label Nov 1, 2025
@cla-bot
Copy link

cla-bot bot commented Nov 1, 2025

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

@playdohface
Copy link
Collaborator

Looks good and works, too. Thank you!

@playdohface playdohface merged commit 046f384 into zed-extensions:main Nov 1, 2025
1 check passed
@acardonna acardonna deleted the add-textobjects branch November 1, 2025 11:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants