How can I configure Ctrl+PgUp and Ctrl+PgDown keybindings in vscode navigate to the top/bottom of the view instead of switching tabs?

旧时模样 提交于 2020-01-25 07:40:06

问题


By default, Ctrl+PageUp and Ctrl+PageDown combinations in Visual Studio Code switch view to the next/previous tab. I would like to reconfigure them so they work like in Visual Studio, so they navigate to the top/bottom of the screen.

I am trying to modify the editor's keybindings (keybindings.json) but I find myself unable to find proper commands.

So far, I have found:

  • cursorTop/cursorBottom - moves cursor to the top/bottom of the whole file
  • scrollLineUp/scrollLineDown - scrolls the view, but does not change cursor's position
  • scrollPageDown/scrollPageUp - moves the view one page down/up, but does not change the cursor's position

I have tried Visual Studio Keymap (https://marketplace.visualstudio.com/items?itemName=ms-vscode.vs-keybindings) extension, but it also does not provide the required functionality.


回答1:


Of course, almost immediately after posting a question I've stumbled upon a solution. This issue comments (https://github.com/Microsoft/vscode/issues/15058) gave me a hint, so I tried cursorMove command with "to": "viewPortTop" and "to": "viewPortBottom" arguments and, surprisingly, it worked.

The complete json to be added to keybindings.json is:

{
    "key": "ctrl+pageup",
    "command": "cursorMove",
    "when": "editorTextFocus",
    "args": {
        "to": "viewPortTop"
    }
}    ,
{
    "key": "ctrl+pagedown",
    "command": "cursorMove",
    "when": "editorTextFocus",
    "args": {
        "to": "viewPortBottom"
    }
}    


来源:https://stackoverflow.com/questions/51554277/how-can-i-configure-ctrlpgup-and-ctrlpgdown-keybindings-in-vscode-navigate-to

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!