zed icon indicating copy to clipboard operation
zed copied to clipboard

Vim Mode - Fold/Unfold using `za`

Open titouandk opened this issue 1 year ago • 2 comments

Check for existing issues

  • [X] Completed

Describe the feature

VSCode has a nice Vim command za to fold / unfold code under cursor.

(This is not a native Vim behavior - Vim is natively more restrictive as you must have an existing fold for this to work.)

https://github.com/zed-industries/zed/assets/5413308/ed95f73c-7f77-4589-a79d-56bab93e716d

This works for all languages, as in markdown:

https://github.com/zed-industries/zed/assets/5413308/1e56ab80-f43b-4703-9e8d-3cf0a59170cc

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

No response

titouandk avatar Jan 26 '24 23:01 titouandk

you can do it with keymaps:

  {
    "context": "Editor && VimControl && !VimWaiting && !menu",
    "bindings": {
      // put key-bindings here if you want them to work in normal & visual mode
      "g f": "editor::Fold",
      "g u": "editor::UnfoldLines"
    }
  },

rauann avatar Jan 27 '24 21:01 rauann

@rauann I might be wrong, but it seems to me that this solution has 2 problems:

  • gu and gf are already existing vim command
  • You have 2 different commands for fold/unfold, instead of only one that acts as a toggle

titouandk avatar Jan 27 '24 21:01 titouandk

Bump! Would love this feature.

soham-suki avatar Jun 19 '24 18:06 soham-suki

Also bump - Feels quite strange not being able to easily fold and unfold things. Are we able to hook the editor's folding controls (To enable the LSP to do a majority of the lifting work and defer to the indenting set there?)

MrDwarf7 avatar Jul 12 '24 20:07 MrDwarf7

Yes we absolutely need editor::ToggleFold!

TKone7 avatar Jul 17 '24 08:07 TKone7