如何在 vscode 中配置 Ctrl+PgUp 和 Ctrl+PgDown 键绑定导航到视图的顶部/底部而不是切换选项卡? [英] How can I configure Ctrl+PgUp and Ctrl+PgDown keybindings in vscode navigate to the top/bottom of the view instead of switching tabs?

查看:35
本文介绍了如何在 vscode 中配置 Ctrl+PgUp 和 Ctrl+PgDown 键绑定导航到视图的顶部/底部而不是切换选项卡?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

默认情况下,Visual Studio Code 中的 Ctrl+PageUp 和 Ctrl+PageDown 组合会将视图切换到下一个/上一个选项卡.我想重新配置它们,以便它们像在 Visual Studio 中一样工作,以便它们导航到屏幕的顶部/底部.

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.

我正在尝试修改编辑器的键绑定 (keybindings.json),但我发现自己无法找到正确的命令.

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

到目前为止,我发现:

  • cursorTop/cursorBottom - 将光标移动到整个文件的顶部/底部
  • scrollLineUp/scrollLineDown - 滚动视图,但不改变光标位置
  • scrollPageDown/scrollPageUp - 将视图向下/向上移动一页,但不改变光标的位置

我尝试过 Visual Studio Keymap (https://marketplace.visualstudio.com/items?itemName=ms-vscode.vs-keybindings) 扩展,但它也不提供所需的功能.

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.

推荐答案

当然,几乎在发布问题后我就偶然发现了一个解决方案.本期评论(https://github.com/Microsoft/vscode/issues/15058) 给了我一个提示,所以我尝试了带有 "to": "viewPortTop""to": "viewPortBottom" 参数的 cursorMove 命令而且,令人惊讶的是,它奏效了.

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.

要添加到 keybindings.json 的完整 json 是:

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

这篇关于如何在 vscode 中配置 Ctrl+PgUp 和 Ctrl+PgDown 键绑定导航到视图的顶部/底部而不是切换选项卡?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆