当光标在 VS Code Vim 中移动时,代码折叠会自动打开.我怎样才能防止这种情况? [英] Code folds are automatically opened when cursor moves over them in VS Code Vim. How can I prevent this?

查看:68
本文介绍了当光标在 VS Code Vim 中移动时,代码折叠会自动打开.我怎样才能防止这种情况?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我喜欢在 VS Code 编辑器中折叠代码,但是即使我折叠了一些代码块,当我使用 VS Code Vim 使用 j/k 将光标移到它们上面时,它们也会被打开延期.如何防止我的代码折叠像这样自动打开?

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?

推荐答案

看起来这是一个 很多人已经有一段时间的问题,解决方案是执行以下操作(原始来源):

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. 打开您的用户设置.在 Windows 上,快捷方式是CTRL + ,
  2. 搜索 vim.foldfix 并选中复选框,将设置设为 true.
  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.

或者,通过打开命令面板 (CTRL + SHIFT + P),选择首选项:打开设置(JSON),然后添加以下行:"vim.foldfix": 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

现在,当您使用 jk 滚动过去时,折叠不应再自动展开.

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

请注意,这是一个 hack,因为 VS Code 本身的各种问题使解决这个问题变得困难.

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

这篇关于当光标在 VS Code Vim 中移动时,代码折叠会自动打开.我怎样才能防止这种情况?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆