zed-industries / zed

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
https://zed.dev
Other
50.32k stars 3.1k forks source link

Add support for Vim text objects like caq and ciq in Vim mode #18295

Open OrlovAlexei opened 1 month ago

OrlovAlexei commented 1 month ago

Check for existing issues

Describe the feature

Please add support for the following Vim commands:

caq: Change around quotes — Changes the entire text inside and around quotes, putting the user in insert mode. ciq: Change inside quotes — Changes only the text inside the quotes, without affecting the quotes themselves. cab: Change around brackets — Changes the entire text inside and around brackets ( ), { }, or [ ], switching to insert mode. cib: Change inside brackets — Changes only the text inside the brackets, keeping the brackets intact. daq / diq: Delete around / inside quotes — Deletes the text around or inside quotes. dab / dib: Delete around / inside brackets — Deletes text inside or around different types of brackets.

If applicable, add mockups / screenshots to help present your vision of the feature

No response

ConradIrwin commented 1 month ago

Are you using a plugin for daq? We should already support da", and dab. I'm not against adding it, but I don't think it's part of vim by default.

The objects we currently support:

https://github.com/zed-industries/zed/blob/44b1399e6c66a5ba4d9a5cdf289458de864a8606/assets/keymaps/vim.json#L373-L396

OrlovAlexei commented 1 month ago

You're right, daq is not a default Vim command. The behavior I was referring to typically comes from the popular plugin vim-surround for Vim or nvim-surround for Neovim, which adds more flexible and powerful manipulation of surrounding text like quotes, brackets, and other delimiters.

I was wondering if there's a way to replicate this behavior manually in Zed, or if you have any suggestions on how I could implement something similar.

Thanks again for your consideration!

OrlovAlexei commented 1 month ago

If I want to implement this via keymaps/vim.json, is it possible to add something like vim::AnyQuotes? AnyQuotes would refer to any of the following: Quotes, BackQuotes, or DoubleQuotes. Could something similar be done for brackets as well?

Thanks again for your consideration!

oca159 commented 1 month ago

This is especially useful when using the English international layout, where entering double quotes (") requires pressing three keys: Shift + " + Space. Instead, I prefer using Vim commands like ciq, caq, diq, and daq for greater efficiency.