VS Code Web:Alt+G 快速跳转到文件
添加 Alt+G 快捷键,一键打开「转到文件」选择器(github.dev 也适用)。
可复制的代码
/* Add Alt+G shortcut to open the Go-to-file quick picker (works on github.dev too) */
(function () {
document.addEventListener('keydown', (e) => {
if (e.altKey && (e.key === 'g' || e.key === 'G') && !e.ctrlKey && !e.metaKey) {
e.preventDefault();
const evt = new KeyboardEvent('keydown', {
key: 'p', code: 'KeyP', ctrlKey: true,
bubbles: true, cancelable: true
});
(document.activeElement || document.body).dispatchEvent(evt);
}
}, true);
console.info('[vsc] Alt+G now opens Go to File');
})();
如何使用此示例
- 用上方按钮复制代码。
- 安装 JustZix(2 分钟),在目标页面打开扩展。
- 添加一条匹配该页面的新规则。
- 将代码粘贴到规则的 JavaScript 面板并保存 — 每次访问页面时都会运行。
为此示例评分
暂无评分 — 成为第一个。