avatarAbhishek Singh

Summary

The web page content provides instructions on how to fix the 'code .' command not working in Visual Studio Code with the Terminal.

Abstract

The web page titled "How to fix code. command not working | Visual Studio Code with the Terminal" explains a common issue faced by users while trying to open a directory in Visual Studio Code using the 'code .' command in the terminal. The author shares a screenshot of the problem and then provides step-by-step solutions for macOS, Windows, and Linux users to link the "code" command with Visual Studio Code (VSCode). The solution involves installing the Shell Command and confirming the installation, which allows the use of the "code" command in the terminal. The author includes screenshots to help users follow along with the process.

Bullet points

  • The problem: users encounter a 'command not found' error when attempting to open a directory in VS Code using the 'code .' command in the terminal.
  • Solution overview: link the "code" command with Visual Studio Code (VSCode) by ensuring that the command is recognized and properly configured in the system's PATH.
  • Solution steps for macOS:
    • Open VSCode
    • Install Shell Command from the command palette
    • Confirm the installation of the "code" command in the PATH
  • Solution steps for Windows:
    • Open VSCode
    • Open the command palette
    • Type "Shell Command" and select "Shell Command: Install 'code' command in PATH"
    • Confirm the installation of the "code" command in the PATH
  • Solution steps for Linux:
    • Open VSCode
    • Open the command palette
    • Type "Shell Command" and select "Shell Command: Install 'code' command in PATH"
    • Confirm the installation of the "code" command in the PATH
  • After performing the steps, users should be able to use the 'code .' command in the terminal or command prompt to open files and directories in Visual Studio Code.
  • If users encounter issues, they should ensure that VSCode is correctly installed and that they have administrative privileges to make changes to their system's PATH.
  • The web page includes a recommendation for a cost-effective AI service similar to ChatGPT Plus(GPT-4).

How to fix code. command not working | Visual Studio Code with the Terminal

While I was in the midst of work, I encountered a problem while attempting to establish a connection between my terminal and Visual Studio Code. Every time I tried to execute the ‘code .’ command from the terminal to open a directory in VS Code, I encountered a ‘command not found’ error. This brief vlog is dedicated to this specific issue and how I successfully resolved it. Let’s get started.

Problem screenshot

Solution :

Self-verified

Linking the “code” command with Visual Studio Code (VSCode) typically involves ensuring that the “code” command is recognized and properly configured in your system’s PATH. Here’s how you can link the “code” command to VSCode:

On macOS:

  1. Open VSCode: Launch Visual Studio Code if it’s not already open.
  2. Install Shell Command: In the top menu, click on “View” and select “Command Palette” or use the keyboard shortcut (Cmd+Shift+P). In the command palette, type "Shell Command" and select "Shell Command: Install 'code' command in PATH."
  3. Confirm Installation: You should see a message confirming the installation of the “code” command in your PATH. This allows you to use the “code” command in your terminal.

On Windows:

  1. Open VSCode: Launch Visual Studio Code if it’s not already open.
  2. Open the Command Palette: Press Ctrl+Shift+P to open the command palette.
  3. Type “Shell Command”: In the command palette, type “Shell Command” and select “Shell Command: Install ‘code’ command in PATH.”
  4. Confirm Installation: You should see a message confirming the installation of the “code” command in your PATH. This allows you to use the “code” command in your terminal.

On Linux:

  1. Open VSCode: Launch Visual Studio Code if it’s not already open.
  2. Open the Command Palette: Press Ctrl+Shift+P to open the command palette.
  3. Type “Shell Command”: In the command palette, type “Shell Command” and select “Shell Command: Install ‘code’ command in PATH.”
  4. Confirm Installation: You should see a message confirming the installation of the “code” command in your PATH. This allows you to use the “code” command in your terminal.

Lets Perform this Step one by one

I will directly attach screenshot

That’s it.

Simple hack and it will save lots of time in your coding journey.

After performing these steps, you should be able to use the “code” command in your terminal or command prompt to open files and directories in Visual Studio Code. For example, you can use the following command to open the current directory in VSCode:

code .

If you encounter any issues, ensure that VSCode is correctly installed and that you have administrative privileges to make changes to your system’s PATH.

Codehippo.co.uk has compiled a selection of other valuable and fundamental Linux commands that can aid in your learning journey

Happy coding

Abhishek Singh

Terminal
Terminal Fix
Bug Fixes
Vscode
Vscode Keyboard Shortcuts
Recommended from ReadMedium