Home Explore Blog CI



zed

2nd chunk of `docs/src/vim.md`
4a3aba4ba655ac09c54316c7347f2ef53682fbef709bd4e90000000100000fd9
> ```json
> {
>   "vim_mode": true
> }
> ```

## Zed-specific features

Zed is built on a modern foundation that (among other things) uses tree-sitter and language servers to understand the content of the file you're editing and supports multiple cursors out of the box.

Vim mode has several "core Zed" key bindings that will help you make the most of Zed's specific feature set.

### Language server

The following commands use the language server to help you navigate and refactor your code.

| Command                                  | Default Shortcut |
| ---------------------------------------- | ---------------- |
| Go to definition                         | `g d`            |
| Go to declaration                        | `g D`            |
| Go to type definition                    | `g y`            |
| Go to implementation                     | `g I`            |
| Rename (change definition)               | `c d`            |
| Go to All references to the current word | `g A`            |
| Find symbol in current file              | `g s`            |
| Find symbol in entire project            | `g S`            |
| Go to next diagnostic                    | `g ]` or `] d`   |
| Go to previous diagnostic                | `g [` or `[ d`   |
| Show inline error (hover)                | `g h`            |
| Open the code actions menu               | `g .`            |

### Git

| Command                         | Default Shortcut |
| ------------------------------- | ---------------- |
| Go to next git change           | `] c`            |
| Go to previous git change       | `[ c`            |
| Expand diff hunk                | `d o`            |
| Toggle staged                   | `d O`            |
| Stage and next (in diff view)   | `d u`            |
| Unstage and next (in diff view) | `d U`            |
| Restore change                  | `d p`            |

### Treesitter

Treesitter is a powerful tool that Zed uses to understand the structure of your code. Zed provides motions that change the current cursor position, and text objects that can be used as the target of actions.

| Command                         | Default Shortcut            |
| ------------------------------- | --------------------------- |
| Go to next/previous method      | `] m` / `[ m`               |
| Go to next/previous method end  | `] M` / `[ M`               |
| Go to next/previous section     | `] ]` / `[ [`               |
| Go to next/previous section end | `] [` / `[ ]`               |
| Go to next/previous comment     | `] /`, `] *` / `[ /`, `[ *` |
| Select a larger syntax node     | `[ x`                       |
| Select a smaller syntax node    | `] x`                       |

| Text Objects                                               | Default Shortcut |
| ---------------------------------------------------------- | ---------------- |
| Around a class, definition, etc.                           | `a c`            |
| Inside a class, definition, etc.                           | `i c`            |
| Around a function, method etc.                             | `a f`            |
| Inside a function, method, etc.                            | `i f`            |
| A comment                                                  | `g c`            |
| An argument, or list item, etc.                            | `i a`            |
| An argument, or list item, etc. (including trailing comma) | `a a`            |
| Around an HTML-like tag                                    | `a t`            |
| Inside an HTML-like tag                                    | `i t`            |
| The current indent level, and one line before and after    | `a I`            |
| The current indent level, and one line before              | `a i`            |
| The current indent level                                   | `i i`            |

Note that the definitions for the targets of the `[m` family of motions are the same as the
boundaries defined by `af`. The targets of the `[[` are the same as those defined by `ac`, though

Title: Zed-Specific Vim Mode Features: Language Server, Git, and Treesitter Integration
Summary
This section details Zed's Vim mode features that leverage Zed's core capabilities, including language server integration for navigation and refactoring (e.g., go to definition, rename), Git integration for navigating changes and staging/unstaging hunks, and Treesitter integration for structural code navigation and selection via motions and text objects (e.g., navigating methods/sections, selecting syntax nodes, and using text objects for classes, functions, and comments).