Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Code folds are automatically opened when cursor moves over them in VS Code Vim. How can I prevent this?

I like to fold code in the VS Code editor, but even when I fold some code blocks, they are opened when I move over them with my cursor using j / k using the VS Code Vim extension. How can I protect my code folds from automatically opening like this?

like image 677
JongHyeon Yeo Avatar asked Jun 16 '18 13:06

JongHyeon Yeo


People also ask

How do you stop a program in VS code?

VS Code maintains a debug session while the program is running, and pressing the Stop button terminates the program.

How use multiple cursor in VS code?

VS Code supports multiple cursors for fast simultaneous edits. You can add secondary cursors (rendered thinner) with Alt+Click. Each cursor operates independently based on the context it sits in. A common way to add more cursors is with Shift+Alt+Down or Shift+Alt+Up that insert cursors below or above.

How do I enable autosave in VS code?

To turn on or turn off the Auto Save feature in Visual Studio Code, go to File and click on Auto Save from the drop-down menu: The steps are completely the same in Windows and macOS. If you want to config the Auto Save behavior deeper, go to: Mac: Code > Preferences > Settings.


1 Answers

It looks like this is an issue many people have had for a while, and the solution is to do the following (original source):

  1. Open up your user settings. On windows the shortcut is CTRL + ,
  2. Search for vim.foldfix and check the checkbox so the setting is set to true.

Alternatively, open your settings.json file by opening the command palette (CTRL + SHIFT + P), select Preferences: Open Settings (JSON), then add the following line: "vim.foldfix": true

Now the folds should no longer automatically expand when you scroll past them with j or k.

Be aware that this is a hack because of various problems with VS Code itself that make fixing this difficult.

like image 97
Mihai Chelaru Avatar answered Sep 24 '22 15:09

Mihai Chelaru