Sam Selikoff
Sam Selikoff

Reputation: 12684

Prevent VSCode from unfolding code when cursor moves past folded section

Is it possible to prevent VSCode from unfolding a folded code section if I move past it with my cursor using the arrow keys?

A common workflow I have coming from Atom is to fold parts of my code, then move my cursor down below the folded sections to get to later sections of a file. If I do this in VSCode, the folded section will unfold as soon as my cursor crosses the top of the section. I want it to move past it instead.

Here's an example:

enter image description here

I searched my prefs and Google for a setting, but couldn't find one.

Upvotes: 16

Views: 2205

Answers (2)

shahid
shahid

Reputation: 71

Use this config:

"vim.normalModeKeyBindings": [
    {
      "before": ["j"],
      "after": ["g", "j"]
    },
    {
      "before": ["k"],
      "after": ["g", "k"]
    }
  ],

Upvotes: 2

Sam Selikoff
Sam Selikoff

Reputation: 12684

My Google-fu failed me when I first opened this but there's plenty of discussion around it, and a fix.

The FAQ for the VSCodeVim extension also says this:

  • Moving j/k over folds opens up the folds

Try setting vim.foldfix to true. This is a hack; it works fine, but there are side effects (see issue#22276).

The fix is working great for me!! Very happy to have solved this.

Upvotes: 19

Related Questions