VSCode + neovim: how to jump half page up/down and center screen vertically?

Viewed 22

In VSCode with the extension vscode-neovim installed:

  • How to set up the keybindings so that, for example, ctrl+u moves the screen a half-page up, and then centers it vertically?
  • Vice-versa for down and full-page up/down.

I tried this in my keybindings.json:

[
  // disable the actual ctrl-u
  {
    "key": "ctrl+u",
    "command": "-vscode-neovim.ctrl-u",
    "when": "editorTextFocus && neovim.ctrlKeysNormal && neovim.init && neovim.mode != 'insert'"
  },

  // send the ctrl-u + z. for centering
  {
    "key": "ctrl+u",
    "command": "vscode-neovim.send",
    "when": "editorTextFocus && neovim.ctrlKeysNormal && neovim.init && neovim.mode != 'insert'",
    "args":  "<C-u>z."
  },
]

But after these changes, half-page up and down commands now jump 100 lines (instead of 20 like before).

Related issue on GitHub: https://github.com/vscode-neovim/vscode-neovim/issues/1039

1 Answers

Problem

The problem seems to be related to the commented-out code from the vscode-scrolling.vim file:

" Disabled due to scroll problems (the ext binds them directly)
" nnoremap <silent> <expr> <C-d> VSCodeExtensionCall('scroll', 'halfPage', 'down')
" xnoremap <silent> <expr> <C-d> VSCodeExtensionCall('scroll', 'halfPage', 'down')
" nnoremap <silent> <expr> <C-u> VSCodeExtensionCall('scroll', 'halfPage', 'up')
" xnoremap <silent> <expr> <C-u> VSCodeExtensionCall('scroll', 'halfPage', 'up')

[...] (same for full page and line)
Related