DEV Community

Neeraj Sharma
Neeraj Sharma

Posted on

How do you open vs code ? 🧐

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.

  1. Using the terminal
  2. 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
Enter fullscreen mode Exit fullscreen mode

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")
Enter fullscreen mode Exit fullscreen mode

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:

  1. Open the registry editor by pressing win + r and typing regedit and pressing enter.
  2. Navigate to HKEY_CLASSES_ROOT\Directory\shell.
  3. Right-click on the shell folder and select New > Key.
  4. Name the key VS Code.
  5. Right-click on the VS Code key and select New > Key.
  6. Name the key command.
  7. Right-click on the command key and select Modify.
  8. Right-click on the VS Code and select New > String Value.
  9. Name the string value to Icon and set the value data to "C:\Program Files\Microsoft VS Code\Code.exe".
  10. 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)