VSCodeVim / VSCodeVim/Vim

Solution for VSCodeVim code folding issue (solves #1004)

Open
#4,517 11 comments 3 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

Solves->
#1004

Introduction->
First of all, thank you for this amazing plugin.
Without a vim plugin, I wouldn't be using vscode.

Thank you very much for your hard work.

Problem ->
vscode vim folding has been an issue for a lot of time and, AFAIK vscode devs havn't fixed the issue and it seems they don't plan to provide the required API to solve these issues.

This has been probably the most requested feature ( #1004 ) for VSCodeVim but due to the negligence of support from core vscode team, I was going to leave vscode behind, out of frustration.

Discussion ->
But I didn't want to leave vscode.

So I came up with a solution myself.

I don't know if it is the "best" solution. It works for me. And I plan to continue using it.

I'm sharing here in hope that if someone else is facing the same problem, they are able to solve the issue and enjoy using vscode.

I'm not noticing any performance degradation due to using this fix, but it's a dirty fix nonetheless.

Use->

  • Setup the macros as shown in solution section.
  • Use alt+j to move down.
  • Use alt+k to move up.

Solution ->
I used macros to setup alternative ways to move up and down which didn't have the code folding issue.

I downloaded this macro plugin : <<< LINK >>>

I included the following setting into settings.json

"macros": {
    "vimAltDown" : [
        "toggleVim",
        "cursorDown",
        "toggleVim"
    ],
    "vimAltUp" : [
        "toggleVim",
        "cursorUp",
        "toggleVim"
    ]
}

I added the following to keybindings.json

{
    "command": "macros.vimAltDown",
    "key": "alt+j"
},
{
    "command": "macros.vimAltUp",
    "key": "alt+k"
}

How it works ->
I used the macro library to setup proper macros that would toggle out of vim mode, move the cursor down or up and toggle vim on again.

When vim mode is toggled off, the cursor can move up and down without expanding the code folds.

Request->
If this is suitable for your needs, could you please include the solution in a more official way?

Thanks

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

Read issue #1004 first, then compare the requested behavior with the workaround described in settings.json and keybindings.json. The issue names no repository files or tests, so first identify the VSCodeVim entry points for cursor movement and folding. Done means providing an official supported way to move through folded code without expanding it.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript, vscode
Domain
developer-experience, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.