VSCode Notebook输出滚动HJKL快捷键配置及聚焦滚动问题
VSCode Notebook输出HJKL滚动配置及聚焦居中问题
一、修复HJKL按键滚动Notebook输出的配置
你当前使用的workbench.action.interactivePlayground.arrowUp/arrowDown是针对交互式Playground的专属命令,无法作用于Notebook输出区域。替换为通用的滚动行命令即可解决:
[ // 单行上下滚动Notebook输出 { "key": "k", "command": "scrollLineUp", "when": "notebookOutputFocused" }, { "key": "j", "command": "scrollLineDown", "when": "notebookOutputFocused" }, // 可选:添加横向滚动支持(针对宽输出内容) { "key": "h", "command": "scrollColumnLeft", "when": "notebookOutputFocused" }, { "key": "l", "command": "scrollColumnRight", "when": "notebookOutputFocused" } ]
保存配置后重启VSCode,聚焦Notebook输出区域时,按K/J就能实现上下滚动,和箭头键效果一致。
二、聚焦Notebook输出并滚动至视图中心的方案
VSCode没有原生的单一命令同时实现“聚焦输出+滚动居中”,但可以通过宏命令组合两个动作完成:
- 安装Multi Command扩展(VSCode扩展市场中可搜索到)
- 在
settings.json中添加宏配置:
"multiCommand.commands": [ { "command": "multiCommand.focusNotebookOutputAndCenter", "sequence": [ "notebook.focusOutput", "editorScroll.center" ] } ]
- 绑定自定义快捷键(示例绑定
Ctrl+Shift+O,可按需修改):
{ "key": "ctrl+shift+o", "command": "multiCommand.focusNotebookOutputAndCenter", "when": "notebookEditorFocused" }
按下绑定的快捷键后,会自动聚焦当前活动单元格的输出,并将其滚动到视图中心位置。
内容的提问来源于stack exchange,提问作者Kael
相关产品推荐
相关产品推荐

