Vim
Vim copied to clipboard
`<C-d>` or `<C-u>` doesn't work when opening a file with imports folded by default.
If a file contains folded imports the <C-d> and <C-u> keys don't work.
Steps to reproduce the behavior:
- Open a JavaScript file with imports and fold them.
- Close file and open it again.
- Try pressing
<C-d>.
Expected behavior:
It's supposed to take you down half a page but those keys don't work. It only starts working if you go to the top of the file and hit j a few times to unfold the lines.
- Extension (VsCodeVim) version: 1.23.1
- VSCode version: 1.69
- OS: MacOS
Just realize that I have very similar problem and also found my solution.
Settings:
"vim.handleKeys": {
"<C-d>": false,
"<C-u>": false,
},
Shortcuts:
// fix <C-d> and <C-u>
{
"key": "ctrl+d",
"command": "cursorMove",
"args": {
"to": "down",
"by": "line",
"value": 34
},
},
{
"key": "ctrl+u",
"command": "cursorMove",
"args": {
"to": "up",
"by": "line",
"value": 34
},
},
That's a cool solution, I was having some inconsistencies with vim handling those two as well, this makes same behaviour but native. Cheers
I was excited about your solution at first but found out that could not use it when I was in visual mode (sometimes I like to select big chunks with C-d and C-u.
An alternative to this is to create vim keybindings for the corresponding modes:
//settings.json
{
//...
"vim.normalModeKeyBindingsNonRecursive": [
{
"before": ["<C-d>"],
"after": ["2", "0", "j"]
},
{
"before": ["<C-u>"],
"after": ["2", "0", "k"]
}
],
"vim.visualModeKeyBindings": [
{
"before": ["<C-d>"],
"after": ["2", "0", "j"]
},
{
"before": ["<C-u>"],
"after": ["2", "0", "k"]
}
]
//...
}
EDIT: misinstructed about vim.handleKeys. <C-d> and <C-u> should be managed by vim
Stole this from #1348
Doesn't have to be the imports that are folded for me. When writing jest tests, I can fold a describe block and this issue happens too.
The same problem happens when I fold any part of any file.