Open your folder and file with VS Code from Finder with a subtle right click!
It's quite a common need to open VS Code from Finder on Mac, especially for those developers who have been accustomed to opening VS Code from File Explorer in Windows with just a slight right click on the target folder or file.
However, VS Code on Mac does not offer this shortcut natively. So here is an easy and subtle way to implement this feature.
- Launch Automator on your Mac.
- Select New Document icon on the bottom of the window (highlighted with red box).
- Choose Workflow as the type for your document.
- Find the 4th category in the Library list on the left side of the window. Click on it and find Open Finder Items. Doubt click on this term or drag it to the pane on the right.
- Choose Visual Studio Code.app as the application of Open with drop down menu.
- Press
Command-S
to save the script to your favourite folder with the name Open in VS Code, which will show on the right click menu when clicking on a folder or file in Finder. Done :)
Notes:
- Automator is a powerful tool natively available in macOS, which aims to design and automate user customized workflow. To open Automator, you can find it from
Application
folder or simple search for it with Spotlight. See Automator User Guide from Apple for more information. - Visual Studio Code.app may not appear in the drop down menu of step 5 as expected. You may need to choose other and find it. Usually the Visual Studio Code.app is in
Application
folder. If not, you may refer to the installation part of Visual Studio Code on macOS to move it here so that you can find it inApplication
folder.
- Now the implementation method only works for opening VS Code with the selected folder or file. It would be great if we can also open VS Code with the current folder in Finder. However, I have not found a way to do this yet. If you have any idea, creating an issue or pull request is more than welcome :)
- The implementation method refers to the second answer of this post on StackOverflow. I organised these steps into a doc with a demo here for everyone who may need it. It's also an open space to explore better implementation for this task.