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
45.14k stars 2.45k forks source link

Code Folding Levels #5142

Open NathBabs opened 1 year ago

NathBabs commented 1 year ago

Check for existing issues

Is your feature request related to a problem?

Going through large files is really difficult.

Describe the solution you'd like

When I open a large file in VS Code, i can immediately fold all the code at a particular nesting level(Cmd + k + 4 (or a number) to be able to go through the code. It is very helpful to me in my DX. And also folding in the UI by the line numbers should be possible. The current folding capability in Zed is too basic to be useful for me

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

No response

JosephTLyons commented 1 year ago

This seems like an interesting feature - I've never used this in other editors. Thanks for the feedback @NathBabs.

JosephTLyons commented 1 year ago

Ran into how cool this was just now when playing with Pulsar to build an Atom keymap for Zed. Being able to select the level of indentation is super nice.

SilentGlasses commented 1 year ago

Atom had this folding feature not sure why it's missing as a basic feature in Zed. Can we get a fold option as part of the line number sidebar?

This is a very handy feature for when dealing with indented code to be able to focus on things within a certain indentation level.

Screen Shot 9

SilentGlasses commented 1 year ago

Also, for simplicity sake, can we bring zed-industries/zed#5787 and zed-industries/zed#5556 into this discussion and close those issues out? It's very confusing to have to navigate three issues for the same topic and devs end up with more menial work having to follow the discussion in multiple places.

krstp commented 1 year ago

Just a note... what I just found useful... CMD+SHIFT+O shows full outline of all the functions. Super easy to navigate.

vuon9 commented 6 months ago

Atom had this folding feature not sure why it's missing as a basic feature in Zed. Can we get a fold option as part of the line number sidebar?

This is a very handy feature for when dealing with indented code to be able to focus on things within a certain indentation level.

Screen Shot 9

What is the name of these vertical lines? It's really helpful to work with python code or yaml in VSCode with these lines, but Zed doesn't have.

SomeoneToIgnore commented 6 months ago

There's an issue for those to be added in Zed, and there they are called "indent guides":

SilentGlasses commented 5 months ago

Sorry @vuon9 .. Those lines are part of Pulsar (formerly Atom), they are called Indent Guides and is a built in feature of the editor.

I stopped using Zed and just moved to Pulsar.

canselcik commented 4 months ago

I'd also like to chime in and state interest for Fold-All.

mkdynamic commented 4 months ago

This is a feature Sublime Text had as well, and something I really miss in Zed.

notpeter commented 1 month ago

For reference, here are the VSCode keyboard shortcuts for folds (source):

  • [x] Fold (⌥⌘[) folds the innermost uncollapsed region at the cursor.
  • [x] Unfold (⌥⌘]) unfolds the collapsed region at the cursor.
  • [ ] Toggle Fold (⌘K ⌘L) folds or unfolds the region at the cursor.
  • [ ] Fold Recursively (⌘K ⌘[) folds the innermost uncollapsed region at the cursor and all regions inside that region.
  • [ ] Unfold Recursively (⌘K ⌘]) unfolds the region at the cursor and all regions inside that region.
  • [ ] Fold All (⌘K ⌘0) folds all regions in the editor.
  • [ ] Unfold All (⌘K ⌘J) unfolds all regions in the editor.
  • [ ] Fold Level X (⌘K ⌘2 for level 2) folds all regions of level X, except the region at the current cursor position.
  • [ ] Fold All Block Comments (⌘K ⌘/) folds all regions that start with a block comment token.
f1nnix commented 1 month ago

Alongside with level-folding, a current-cursor-level folding will be super-handy

image
asins commented 1 month ago

This issue began to be discussed in 2022, and it is surprising that it has not yet entered the development plan.

Using the 'Cmd+Shift+o' component key alleviates the problem, but it's still intolerable to the habit.

gazhay commented 1 month ago

Just arrived from linux, and yup can't stay if folding is not a "zed" thing.

equt commented 1 month ago

This would also help to enable the zM (close all folds) in Vim.

maxhoffmann commented 3 weeks ago

Oh no, I also just realized this feature is missing in Zed. It’s very handy in JS to fold all cases of a switch statement, since these don’t show up in the outline for example

Francisneibl commented 3 weeks ago

Any predictions on when this feature will be released?

achalddave commented 2 days ago

Not sure if this is the best place to share, but for zM and zR, the following workaround works okay for me:

  {
    "context": "vim_mode == normal",
    "bindings": {
      "z M": ["workspace::SendKeystrokes", "cmd-a z c escape g g"] // fold all
    }
  },
  {
    "context": "vim_mode == normal",
    "bindings": {
      "z R": ["workspace::SendKeystrokes", "cmd-a z o escape g g"] // unfold all
    }
  }