VSCodeVim / VSCodeVim/Vim

zA (toggle fold recursively) does not work

Open Beginner friendly
#10,059 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
15.2k
Forks
1.5k
Avg merge
3d 18h
Merged PRs (30d)
6

Description

Is your feature request related to a problem? Please describe.
In real Vim, zA toggles the fold under the cursor recursively. It closes an open fold (and all its nested folds), or opens a closed fold (and all its nested folds), depending on the current state. In VSCodeVim, za (single-level toggle), zO (recursive open), and zC (recursive close) all work as expected, but zA does nothing at all. It isn't implemented in src/actions/commands/fold.ts.

Describe the solution you'd like
Add a zA action that determines whether the fold under the cursor is currently closed (e.g. by checking whether the line right after the fold header is present in the editor's visibleRanges) and dispatches editor.unfoldRecursively or editor.foldRecursively accordingly, mirroring how zO/zC already dispatch their respective VS Code commands.

Describe alternatives you've considered
Binding zA to a fixed VS Code command (editor.foldRecursively or editor.unfoldRecursively) via vim.normalModeKeyBindingsNonRecursive was considered, but that only ever does one direction, not a real toggle, since VS Code has no built-in "toggle fold recursively" command to bind to directly.

Additional context
I have a small patch ready that implements this using the visibleRanges state-check approach above and will open a PR referencing this issue.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/actions/commands/fold.ts by reading the existing zO, zC, and za actions and checking how visibleRanges is accessed. Implement zA so it chooses recursive fold or unfold based on the fold's current visibility, then verify that it toggles both open and closed folds recursively.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript, vscode
Domain
developer-experience, tooling
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
76/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.