Vim icon indicating copy to clipboard operation
Vim copied to clipboard

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

Open Shubhamsm opened this issue 4 years ago • 18 comments

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):

  • Extension (VsCodeVim) version: v1.17.1
  • VSCode version: VScodium v1.49.2
  • OS: Kubuntu 20.04

Shubhamsm avatar Sep 30 '20 08:09 Shubhamsm

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

JW9506 avatar Sep 30 '20 09:09 JW9506

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.

BlameTroi avatar Oct 26 '20 22:10 BlameTroi

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

J-Fields avatar Oct 26 '20 23:10 J-Fields

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

BlameTroi avatar Oct 27 '20 03:10 BlameTroi

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?

uloco avatar May 02 '22 11:05 uloco

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 👍

ttytm avatar Jun 29 '22 20:06 ttytm

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"
      ]
    }
  ],

}

prophetw avatar Aug 30 '22 02:08 prophetw

@prophetw

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

uloco avatar Aug 30 '22 09:08 uloco

@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"
      ]
    },

prophetw avatar Sep 02 '22 05:09 prophetw

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

...

This is awesome!

miranquil avatar Oct 11 '22 00:10 miranquil

@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 <C-d> and <C-u>. I've always wanted to set the scroll distance a little less than half a page. Now I can! ❤

cpakken avatar Dec 14 '22 04:12 cpakken

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.

robertpiosik avatar May 22 '23 18:05 robertpiosik

@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

OkkarMin avatar Jun 07 '23 13:06 OkkarMin

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

cpajonk avatar Jun 07 '23 13:06 cpajonk

Genious!

EnhaoSun avatar Jun 12 '23 10:06 EnhaoSun

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"]
    }]

huydq189 avatar Jan 24 '24 04:01 huydq189

@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"]
    }
  ],

ooyay avatar Feb 01 '24 17:02 ooyay

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"
      ]
    }

snobb avatar Jun 11 '24 15:06 snobb