Folding: `zx` for updating folds/collapsing all other folds
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.
I would often like to collapse all folds except for the one at the cursor position.
Describe the solution you'd like
From :help folding in vim: "It may happen that folds are not updated properly. You can use zx or zX to force updating folds."
The effect of this is to collapse all folds that the cursor position is not a part of.
E.g.,
int main(int argc, char *argv[])
{
if (argc > 1)
{
std::cout << argc << std::endl; // <- cursor position
if (argc > 2)
{
call_some_function();
}
}
if (argc > 1)
{
std::cout << argc << std::endl;
if (argc > 2)
{
call_some_function();
}
}
return 0;
}
would collapse to
int main(int argc, char *argv[])
{
if (argc > 1)
{
std::cout << argc << std::endl; // <- cursor position
if (argc > 2)
+---- 3 lines: {················································································
}
if (argc > 1)
+--- 7 lines: {·················································································
return 0;
}
Describe alternatives you've considered
- Using
ctrl-k ctrl-1throughctrl-k ctrl-7approximates this up to a limit, but involves 14 keystrokes and stops at fold level 7. - Using
zMthen<line number>Gand<column number>|essentially performs the desired operation, but involves 6-10 keystrokes on average and requires remembering the line and column numbers of the cursor position.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by comparing the requested zx behavior with the existing Ctrl-K fold commands and zM behavior in VSCodeVim. Implement folding that preserves the cursor's containing folds while collapsing others, then verify it against the C++ example and the stated alternatives.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript, vscode
- Domain
- developer-experience, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100