Vim icon indicating copy to clipboard operation
Vim copied to clipboard

Cursor movement (not jump) opens newly folded range

Open wolf0403 opened this issue 11 months ago • 4 comments

Describe the bug Cursor movement across folded ranges unfolds the lines, instead of move over the folded range like a single line (which is what this was intended to be in vim).

To Reproduce Steps to reproduce the behavior:

  1. zf, e.g. zf3j
  2. j (to go to next line)

Expected behavior

In VIM, cursor will be moved to the next line after the newly created fold in step 1

In VSCodeVim, moving cursor (j/k) will unfold and move the cursor into the unfolded, "physical" line.

Screenshots If applicable, add screenshots to help explain your problem. If remapping-related, please attach log output: https://github.com/VSCodeVim/Vim#debugging-remappings.

Environment (please complete the following information):

  • Extension (VsCodeVim) version: 1.27.2
  • VSCode version: vscode.dev, 1.87.2
  • OS: macOS, Chrome

Additional context Add any other context about the problem here.

wolf0403 avatar Mar 14 '24 11:03 wolf0403

I think what you described is the expected behaviour in VSCodeVim and you can use gj and gk instead of j and k to achieve what you expected.

You can create a remap in your settings.json with something like this:

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

shinohara-rin avatar Mar 14 '24 20:03 shinohara-rin

So if I'm understanding you correctly, this difference in behaviour from vim is expected? And why this change? If I'm creating a fold it generally means I know I don't want to look at them unless specifically to, but now that in VSCodeVim the most frequently used cursor moving keys (j/k) will simply expand this. Why is the default behaviour here instead of what vim is doing?

wolf0403 avatar Mar 15 '24 05:03 wolf0403

I can't say for certain why it's implemented this way in VSCodeVim as I didn't write it, but anyway you can always remap it.

shinohara-rin avatar Mar 15 '24 09:03 shinohara-rin

you can add this settings:

"vim.foldfix": true,

to fix the fold bug

HenryTSZ avatar Mar 15 '24 09:03 HenryTSZ