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
49.15k stars 2.97k forks source link

vim-mode commands #5575

Closed HanEmile closed 1 year ago

HanEmile commented 2 years ago

Before you begin Check the backlog of issues to reduce the chances of creating duplicates; if an issue already exists, place a +1 (👍) on it.

Is your feature request related to a problem? Please describe. my muscle memory kicked in and resulted in me being confused

Describe the solution you'd like So in vim, entering a colon ":" allows to enter a command, such as ":w" saving the current buffer. This currently doesn't happen which is kind of confusing, as when entering ":w", I'd expect that a pane pops up and let's me enter some command or so.

Describe alternatives you've considered I thought of dropping everything in normal mode entered after a colon, until enter is pressed, although that might be even more confusing. Maybe some of you have an Idea on how to handle this in a more vim like fashion?

Screenshots Not applicable

Kethku commented 2 years ago

I'm not sure what this should look like yet as I'm not super keen on adding a ui affordance just for vim mode commands.

I understand that muscle memory is such that certain commands (:w for instance) are hard to move past, but command mode is pretty clunky for a lot of things.

One option might be to extend the command palette to parse a subset of vim commands when vim mode is enabled, and call it there.

Currently I'm avoiding this issue in favor of standard zed bindings (cmd+s saves across modes unless rebound).

Something that might help is some insight into what features you find to be missing that command mode provides. That might help us bump the priority up a bit.

lucastrvsn commented 2 years ago

In the future I think would be great to allow us (plugin authors) to hook into command palette and other places of the Zed UI. I think would be great to have the commands: :vsp :sp /<search> :%s/<find>/<replace> etc, and also the extremelly powerful q to record macros.

In VSCode we have a plugin called VSCodeVim that allow us to use the statusbar at the bottom to simulate the actual vim command line, which is so nice and screen space efficient. I don't think these kind of stuff is something Zed should have out-of-the-box but I think is good to allow us to extend those functions using some sort of plugin system (I don't know if Zed has the intention of allowing plugin development).

My dream editor will allow me to do some features of neovim itself (but Zed is almost my dream at the moment):

Everything else Zed already has and I see a bright future for this editor. Thank you for all the work Zed team! ❤️

dustypomerleau commented 2 years ago

Vim emulation is a massive project, and can be a bit of a thankless task—power Vim users will quickly find every feature you haven't implemented, and both sides end up frustrated.

The model that changed everything for me was the one used by VSCode Neovim. Unlike VSCode Vim, VSCode Neovim passes the buffer off to a running instance of Neovim (rather than attempting emulation). I'm able to load init.vim, use all my Vim plugins (Easymotion, Surround), and still take advantage of VS Code's features. The experience is remarkably good, and allows both the IDE devs and the plugin dev to offload most of the work to Neovim itself, focusing only on the integration, rather than emulation. I jumped at the chance to sponsor the project, and I think there would be interest in supporting a Zed plugin with the same goals.

ramtinabadi commented 1 year ago

Vim commands are necessary. I personally prefer to use Vim motions in a performant IDE with a good ecosystem than terminal. But one of the main reasons of using Vim is to be able to use the same set of commands and key bindings in all platforms and environments. If I need to modify a file via terminal, I can open up Vim and use my existing muscle memory and knowledge to get things done quickly.

Getting used to the native Zed commands (cmd+s, etc.) defeats the purpose of being platform-agnostic.

I agree with @dustypomerleau as Vim emulation is extremely massive and probably not the best use of resources. A better approach would be to find a way to embed Neovim, let it handle most of the work and focus more on the integration.

In my opinion, a solid and performant implementation of Vim (better than VSC) can bring a lot of users to Zed. NVChad is a great testament that many people don't want to build up their own rc from the scratch and would prefer a good setup with a good ecosystem. Zed can be the alternative to the terminal to those who want to use Vim motions and commands but not the customization.

ConradIrwin commented 1 year ago

A first version of this shipped in Zed v0.106 preview! I've put some documentation here: https://docs.zed.dev/general/vim. Please download the preview release, try it out, and let me know what is missing for your workflow using the editor's built in feedback or opening new issues for specific commands.

izuzak commented 1 year ago

Oh wow, this is aaaaamazing, @ConradIrwin! 😍 Thanks so much for adding this -- the :%s// one was something I really missed.

From the docs:

Most importantly, regular expressions use the rust regex crate not vim's custom engine, so the syntax differs slightly.

Would it be possible to add a few examples to highlight key differences? Definitely not urgent, but it would make it much easier for folks since they wouldn't need to read the crate's docs and compare every bit to vim's docs.

Thanks again for this useful feature! ⚡