When using VSCode on Windows, I can navigate the file explorer and hit Enter on the focused file and the file will open in the editor. On my Mac, however, when I do this, VSCode will open the rename input as follows:
I'm not sure why it does this. Even in other text editors (e.g. Atom), the default behavior is to open the file on Enter. Is there any way to change this behavior so that the file opens on Enter? The only workaround I've found so far is CTRL+Enter, which opens the file in a new pane, but with a 3 pane limit in VSCode, this is quite limiting.
So I ran into this as well, but the keyboard shortcuts that I ended using is to map
cmd+enter
to rename and removing the renameFile fromenter
.For me, I have to do
command
0
and then do acommand
down
This brings me to the explorer and then opens the file I select. In Atom, I just had to hitenter
to open the file, I find this to be a strange behavior.vscode v 1.21.1
onOSX
Not sure why the "enter" behavior is different, I am not sure "enter" alone is set in the keybindings on your system or its just defaults to different behaviors based on OS standards...
The good news is, what you are looking for is CTRL+P or CTRL+O
CTRL+P let's you find a file, and CTRL+O should open it (the exact behavior you'd like)
You may also be able to add "Enter" as a possibility for the "workbench.action.files.openFile" command, but not sure if that will break anything if you do. Try it, or just get used to using CTRL+O on both platforms!
More info:
https://code.visualstudio.com/Docs/customization/keybindings
In version 1.19.2, on the mac I was able to go to keyboard shortcuts (menu bar > code > preferences > keyboard shortcuts), search for "rename," and edit "renameFile" ("When" value is "explorerViewletVisible && filesExplorerFocus && !inputFocus") changing the shortcut to "cmd+enter."
You can also past the following in your keybindings.json (there's a link to it on the keyboard shortcuts page):
Enter now opens the highlighted file in the explorer and ctrl+enter puts it in rename/edit mode.
–Edit–
After I upgraded to 1.21.0 the enter key started functioning as renameFile again. cmd+enter still functioned as renameFile as well. To fix this either go to menu bar > code > preferences > keyboard shortcuts and right-click the offending entry and remove it or add a hyphen/minus sign to the beginning of the command in keybindings.json:
On my Mac, simply hitting the Spacebar opens the file for me.
I tried to remove the shortcut of "Rename", which has the Keybinding of "Enter". Then it opens the file properly when I press "Enter".