When I was a beginner, I used to open VsCode and then open the project by selecting the open folder option. Then, I navigated to the project folder in the file chooser and selected the project.
However as I became more experienced, I started using the terminal to open the project.
This is a small thing but it saves a lot of time and makes you feel like an experienced programmer 😎.
Using a terminal gives me a sense that I have control over my computer and I can do anything with it. It's like I am the boss of my computer 😂.
I know it's a small thing but it's the small things that make a big difference.
In this post, I'll share with you the different ways to open a project in vscode. I use the following ways to open vs code.
- Using the terminal
- Custom vs code explorer Context menu
Using the terminal
I use this method most of the time. For the terminal, I use Powershell because it's simple and powerful uses object-oriented commands and is cross-platform. Although you can use the built-in Windows PowerShell, the modern PowerShell has become a more focused tool by Microsoft. Know more about it here. You can download it from here
Setting up the terminal
Let's create a shortcut to launch the terminal.
Search the terminal in the start menu and right click on it and select open file location.
You'll find the shortcut to the terminal in the file explorer. Right-click on the shortcut and select properties. and then click on the shortcut key field and press the key you want to use as a shortcut key. I use ctrl + alt + t
.
when done, click on apply and then ok.
Now you can open the terminal by pressing ctrl + alt + t
.
Optionally you can create an env variable for your projects directory. This will make it easier to navigate to the project directory like so:
$env:Projects = "C:\Users\username\Projects"
code $env:Projects/MyProject
Create a Environment variable
You can create an environment variable for each terminal session by running the following command in the terminal:
[System.Environment]::SetEnvironmentVariable("Projects", "C:\Users\username\Projects", "User")
Custom context menu entry
We can also crete a custom context menu entry in the file explorer to open the project in vscode. This is useful when you want to open the project in vscode without using the terminal.
You might not see the VS Code
option in the context menu. You can add it by following these steps:
- Open the registry editor by pressing
win + r
and typingregedit
and pressing enter. - Navigate to
HKEY_CLASSES_ROOT\Directory\shell
. - Right-click on the
shell
folder and selectNew > Key
. - Name the key
VS Code
. - Right-click on the
VS Code
key and selectNew > Key
. - Name the key
command
. - Right-click on the
command
key and selectModify
. - Right-click on the
VS Code
and selectNew > String Value
. - Name the string value to
Icon
and set the value data to"C:\Program Files\Microsoft VS Code\Code.exe"
. - In the value data field, type
"C:\Program Files\Microsoft VS Code\Code.exe" "%1"
and click OK.
Now you can open the project directory in vscode by right-clicking on the project directory and selecting VS Code
.
The following video shows how to add the VS Code
option in the context menu.
Conclusion
I hope you found this post helpful. If you have any questions or suggestions, feel free to comment your thoughts below.
Join Our Community
Stay connected and join our Telegram community for more tips and discussions!
Join the telegram community here and channel here.
Happy coding! 😎🚀
Top comments (0)