[英]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.