[英]VSCode: Open file from file explorer with Enter key on Mac OSX
如果其他人遇到此问题,在 Mac 上的 VSCode 中从文件资源管理器打开文件的键盘快捷键是:
CMD +向下
这也适用于 Finder。
我最终在这里编译了一些解决方案以获得以下keybinding.json
版本(通过Code > Preferences > Keyboard Shortcuts > keybindings.json
打开Code > Preferences > Keyboard Shortcuts > keybindings.json
):
{
"key": "cmd+enter",
"command": "renameFile",
"when": "explorerViewletVisible && filesExplorerFocus"
},
{
"key": "enter",
"command": "-renameFile",
"when": "explorerViewletVisible && filesExplorerFocus"
},
{
"key": "enter",
"command": "list.select",
"when": "listFocus && !inputFocus"
}
在 1.19.2 版本中,在 Mac 上,我可以转到键盘快捷键(菜单栏 > 代码 > 首选项 > 键盘快捷键),搜索“重命名”,然后编辑“重命名文件”(“何时”值为“explorerViewletVisible && filesExplorerFocus” && !inputFocus") 将快捷方式更改为“cmd+enter”。
您还可以在 keybindings.json 中粘贴以下内容(在键盘快捷键页面上有一个链接):
{
"key": "cmd+enter",
"command": "renameFile",
"when": "explorerViewletVisible && filesExplorerFocus && !inputFocus"
}
Enter 现在在资源管理器中打开突出显示的文件,ctrl+enter 将其置于重命名/编辑模式。
-编辑-
升级到 1.21.0 后,回车键再次开始用作 renameFile。 cmd+enter 仍然起到 renameFile 的作用。 要解决此问题,请转到菜单栏 > 代码 > 首选项 > 键盘快捷键,然后右键单击违规条目并将其删除,或者在 keybindings.json 中的命令开头添加连字符/减号:
{
"key": "enter",
"command": "-renameFile",
"when": "explorerViewletVisible && filesExplorerFocus && !explorerResourceIsRoot && !inputFocus"
}
在我的 Mac 上,只需按空格键即可为我打开文件。
所以我也遇到了这个问题,但我结束使用的键盘快捷键是映射cmd+enter
以重命名并从enter
删除 renameFile 。
{
"key": "cmd+enter",
"command": "renameFile",
"when": "explorerViewletVisible && filesExplorerFocus"
},
{
"key": "enter",
"command": "-renameFile",
"when": "explorerViewletVisible && filesExplorerFocus"
}
cmd+down
在 Mac 10.10.5 上使用 VSCode 1.10.2 对我不起作用。
但是, cmd+enter
对我有用。
或者,如果您想设置自己的键绑定以从文件资源管理器打开文件,请将这些行添加到您的keybindings.json
:
// open file from File Explorer
{ "key": "enter", "command": "list.select",
"when": "explorerViewletVisible && filesExplorerFocus" },
(当然,您可以将enter
更改为您想要的任何组合键)。
我试图删除具有“Enter”键绑定的“重命名”快捷方式。 然后当我按“Enter”时它会正确打开文件。
对我来说,我必须先执行command
0
,然后再执行down
command
down
这会将我带到资源管理器,然后打开我选择的文件。 在 Atom 中,我只需按enter
键即可打开文件,我发现这是一种奇怪的行为。 OSX
上的vscode v 1.21.1
在偏好中:
代码 -> 首选项 -> 键盘快捷键
将此添加到您的 keybindings.json
{
"key": "ctrl+n",
"command": "workbench.action.files.newFile"
}
在可能包含或不包含您设置的其他键绑定的数组中。 保存 keybindings.json
然后当您导航到文件资源管理器中的目录时,您可以使用 ctrl+n 创建一个新文件
不知道为什么“输入”行为不同,我不确定“输入”是在系统的键绑定中单独设置的,还是根据操作系统标准默认为不同的行为......
好消息是,您正在寻找的是 CTRL+P 或 CTRL+O
CTRL+P 让你找到一个文件,CTRL+O 应该打开它(你想要的确切行为)
您也可以为“workbench.action.files.openFile”命令添加“Enter”作为一种可能性,但不确定这样做是否会破坏任何内容。 试试吧,或者只是习惯在两个平台上使用 CTRL+O!
更多信息:
https://code.visualstudio.com/Docs/customization/keybindings
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.