VSCodeVim / Vim

:star: Vim for Visual Studio Code
http://aka.ms/vscodevim
MIT License
13.97k stars 1.32k forks source link

`<C-d>` , `<C-u>` not working when code folded #5303

Open Shubhamsm opened 4 years ago

Shubhamsm commented 4 years ago

Describe the bug

Navigating using Ctrl-D Ctrl-U not working when code is folded cursor stucks there when it encounters a folded code

Environment (please complete the following information):

JW9506 commented 4 years ago

As an alternative, use L, H if you have set "editor.cursorSurroundingLines": 3, or use native vscode command scrollLineDown, scrollPageDown.

BlameTroi commented 4 years ago

VSCode v1.50.1, VsCodeVim v1.17.1 on Windows 10, I see the same behavior as @Shubhamsm and the problem also occurs with ctrl-f and ctrl-b.

J-Fields commented 4 years ago

This is more or less a duplicate of #5088, see this comment

BlameTroi commented 4 years ago

Thanks for the update. Good enough for me. Too bad VSCode isn't being friendly wrt folds. Carrying on.

uloco commented 2 years ago

Is there any way we can fix this at the current stage of vscode? Does anyone know if there has been improvements in the fold api?

ttytm commented 2 years ago

yeah, this drove me crazy. Avoided using code because of it. But I wrote an extension to solve it.

https://github.com/tobealive/german-scroll.code 👍

prophetw commented 2 years ago

ctrl+d half page scroll vscode scrollPageDown hole page scroll How about use vscode scrollPageDown to handle ctrl+d


{
"vim.normalModeKeyBindingsNonRecursive": [
{
"before": [
"<C-d>"
],
"commands": [
"scrollPageDown"
]
},
{
"before": [
"<C-u>"
],
"commands": [
"scrollPageUp"
]
}
],

}

uloco commented 2 years ago

@prophetw

This unfortunately does not move your cursor but just the view which is not the same behavior.

prophetw commented 2 years ago

@uloco You're right! So at last i do some tricks like this

    {
      "before": [
      "<C-d>"
      ],
      "after": [
        "1",
        "5",
        "g",
        "j",
        "z",
        "z",
      ]
    },
    {
      "before": [
        "<C-u>"
      ],
      "after": [
        "1",
        "5",
        "g",
        "k",
        "z",
        "z"
      ]
    },
miranquil commented 2 years ago

@uloco You're right! So at last i do some tricks like this

...

This is awesome!

cpakken commented 1 year ago

@uloco You're right! So at last i do some tricks like this

    {
      "before": [
      "<C-d>"
      ],
      "after": [
        "1",
        "5",
        "g",
        "j",
        "z",
        "z",
      ]
    },
    {
      "before": [
        "<C-u>"
      ],
      "after": [
        "1",
        "5",
        "g",
        "k",
        "z",
        "z"
      ]
    },

This is actually better than the native implementation of and . I've always wanted to set the scroll distance a little less than half a page. Now I can! ❤

robertpiosik commented 1 year ago

yeah, this drove me crazy. Avoided using code because of it. But I wrote an extension to solve it.

https://github.com/tobealive/german-scroll.code +1

This ext actually solves the issue and perhaps solution could inspired.

OkkarMin commented 1 year ago

@uloco You're right! So at last i do some tricks like this

    {
      "before": [
      "<C-d>"
      ],
      "after": [
        "1",
        "5",
        "g",
        "j",
        "z",
        "z",
      ]
    },
    {
      "before": [
        "<C-u>"
      ],
      "after": [
        "1",
        "5",
        "g",
        "k",
        "z",
        "z"
      ]
    },

Its 2023 and this solution is simple and cleanest

cpajonk commented 1 year ago

Its 2023 and this solution is simple and cleanest

Not for me. This won't get relative half page and full page sizes like the extension or native solution would do. You could count the lines manually and try do add it but it would get verbose and stop working correctly as soon as you change your zoom level or work on another device or with another VSCode window size.

I'm using the german scroll extension which is simpler and cleaner. You maybe wanted to go too simple here @OkkarMin

EnhaoSun commented 1 year ago

Genious!

huydq189 commented 9 months ago

for all who struggle with this issue like me install these extensions:

then add these to vscode setting

"vim.normalModeKeyBindingsNonRecursive": [
    {
      "before": ["<C-u>"],
      "commands": ["germanScroll.bertholdUp", "center-editor-window.center"]
    },
    {
      "before": ["<C-d>"],
      "commands": ["germanScroll.bertholdDown", "center-editor-window.center"]
    }]
ooyay commented 9 months ago

@uloco You're right! So at last i do some tricks like this

...

Without zz works better for me, tysm<3


  "vim.normalModeKeyBindingsNonRecursive": [
    {
      "before": ["<C-d>"],
      "after": ["1", "5", "g", "j"]
    },
    {
      "before": ["<C-u>"],
      "after": ["1", "5", "g", "k"]
    }
  ],
snobb commented 5 months ago

Nice thanks everybody ended up doing this:

    {
      "before": [
        "<C-d>"
      ],
      "after": [
        "1", "2", "g", "j"
      ]
    },
    {
      "before": [
        "<C-u>"
      ],
      "after": [
        "1", "2", "g", "k"
      ]
    },
    {
      "before": [
        "<C-f>"
      ],
      "after": [
        "2", "5", "g", "j"
      ]
    },
    {
      "before": [
        "<C-b>"
      ],
      "after": [
        "2", "5", "g", "k"
      ]
    }