Visual Studio Code In Mac



  1. Visual Studio Code In Mac
  2. 'code .' Not Working In Command Line For Visual Studio Code ...
  3. Macos - Indent/format Code In Visual Studio Code On MAC ...

Develop, build, flash, monitor, debug and more with Espressif chips using Espressif IoT Development Framework (ESP-IDF).

Quick links

Prerequisites

Syncing Visual Studio Code settings between Mac and Windows 13th May 2020. When I got my Windows computer, the first thing I did was to set up Windows so it mirrors the writing system I had on Mac. I also mirrored Mac’s modifiers as much as possible. Editor behaviors can be set to allow code to be formatted as it is written. These actions are set under Visual Studio Preferences Text Editor Behavior, and some of the more commonly used functions are described below: Matching closing braces can be added automatically to code when creating new classes, methods, or properties.

There are few dependencies required in your system and available in environment variable PATH before installing this extension:

Open Visual Studio Code and press Command + Shift + P or F1 then type Shell in command palette now you are able to find this option like Shell Command: Install code in PATH from suggested list in command palette. The Visual Studio Mac native editor shares code with Visual Studio on Windows The C# editor in VS Mac was rewritten by the Visual Studio team after the Microsoft acquisition. It now has what Microsoft calls a 'fully native UI', raising the interesting question of how much of the old MonoDevelop code, which used cross-platform Gtk#, remains in.

LinuxMacOSWindows
Python 3.5+Python 3.5+Python 3.5+
GitGitGit
CMakeCMake
Ninja-buildNinja-build

All the other dependencies like ESP-IDF and ESP-IDF Tools can be installed using the ESP-IDF: Configure ESP-IDF extension setup wizard or following the steps in the setup documentation.

Please note that this extension only supports the release versions of ESP-IDF, you can still use the extension on master branch or some other branch, but certain feature might not properly work.

  • Install this extension in your Visual Studio Code.

  • Then

    • Either open Visual Studio Code and create a workspace folder.
    • Run code ${YOUR_PROJECT_DIR} from the command line.
  • Check you have installed the Prerequisites

  • Press F1 and type ESP-IDF: Configure ESP-IDF extension to open the extension configuration wizard. This will install ESP-IDF and tools and configure the extension.

  • Please take a look at SETUP for details about extension configuration.

  • Press F1 and type ESP-IDF: Create ESP-IDF project to generate a template ESP-IDF project.

  • Configure the .vscode/c_cpp_properties.json as explained in C/C++ Configuration.

    Note: If you want to get code navigation and ESP-IDF function references, the Microsoft C/C++ Extension can be used to resolve header/source links. By default, projects created with ESP-IDF: Create ESP-IDF project tries to resolve headers by manually recursing ESP-IDF directory sources with the Tag Parser engine. This can be optimized by building the project first and configure your project to use build/compile_commands.json as explained in C/C++ Configuration.

  • Do some coding!

  • Check you set the correct port of your device by pressing F1, typing ESP-IDF: Select port to use: and choosing the serial port your device is connected.

  • When you are ready, build your project. Then flash to your device by pressing F1 and typing ESP-IDF: Flash your device then selecting Flash allows you to flash the device.

  • You can later start a monitor by pressing F1 and typing ESP-IDF: Monitor your device which will log the activity in a Visual Studio Code terminal.

  • If you want to start a debug session, just press F5 (make sure you had at least build and flash once before so the debugger works correctly). To make sure you can debug your device, set the proper idf.openOcdConfigs settings in your settings.json or by pressing F1 and typing ESP-IDF: Device configuration.

Click F1 to show Visual studio code actions, then type ESP-IDF to see possible actions.

Command DescriptionKeyboard Shortcuts (Mac)Keyboard Shortcuts (Windows/ Linux)
Add Arduino ESP32 as ESP-IDF Component
Add Editor coverage
Add vscode configuration folder
Build, Flash and start a monitor on your device⌘ E DCtrl E D
Build your project⌘ E BCtrl E B
Configure ESP-IDF extension
Configure Paths
Create project from extension template⌘ E CCtrl E C
Create new ESP-IDF Component
Device configuration
Dispose current SDK Configuration editor server process
Doctor command
Flash your project⌘ E FCtrl E F
Full clean project⌘ E XCtrl E X
Get HTML Coverage Report for project
Install ESP-ADF
Install ESP-IDF Python Packages
Install ESP-MDF
Monitor your device⌘ E MCtrl E M
New Project⌘ E NCtrl E N
Open ESP-IDF Terminal⌘ E TCtrl E T
Open NVS Partition Editor
Pick a workspace folder
SDK Configuration editor⌘ E GCtrl E G
Search in documentation...⌘ E QCtrl E Q
Select port to use⌘ E PCtrl E P
Select OpenOCD Board Configuration
Set default sdkconfig file in project
Set Espressif device target
Show Examples Projects
Show ninja build summary
Size analysis of the binaries⌘ E SCtrl E S
Remove Editor coverage

The Add Arduino-ESP32 as ESP-IDF Component command will add Arduino-ESP32 as a ESP-IDF component in your current directory (${CURRENT_DIRECTORY}/components/arduino). You can also use the Create ESP-IDF project command with arduino-as-component template to create a new project directory that includes Arduino-esp32 as an ESP-IDF component.

NOTE Not all versions of ESP-IDF are supported. Make sure to check Arduino-ESP32 to see if your ESP-IDF version is compatible.

The Install ESP-ADF will clone ESP-ADF to a selected directory and set idf.espAdfPath (idf.espAdfPathWin in Windows) configuration setting.

The Install ESP-MDF will clone ESP-MDF to a selected directory and set idf.espMdfPath (idf.espMdfPathWin in Windows) configuration setting.

The Show Examples Projects command allows you create a new project using one of the examples in ESP-IDF, ESP-ADF or ESP-MDF directory if related configuration settings are set.

Commands for tasks.json and launch.json

We have implemented some utilities commands that can be used in tasks.json and launch.json like

as shown in the debugging documentation.

  • espIdf.getExtensionPath: Get the installed location absolute path.
  • espIdf.getOpenOcdScriptValue: Return the value of OPENOCD_SCRIPTS from idf.customExtraVars or from system OPENOCD_SCRIPTS environment variable.
  • espIdf.getOpenOcdConfig: Return the openOCD configuration files as string. Example '-f interface/ftdi/esp32_devkitj_v1.cfg' -f board/esp32-wrover.cfg.
  • espIdf.getProjectName: Return the project name from current workspace folder build/project_description.json.
  • espIdf.getXtensaGcc: Return the absolute path of the xtensa toolchain gcc for the ESP-IDF target given by idf.adapterTargetName configuration setting and idf.customExtraPaths.
  • espIdf.getXtensaGdb: Return the absolute path of the xtensa toolchain gdb for the ESP-IDF target given by idf.adapterTargetName configuration setting and idf.customExtraPaths.

Available Tasks in tasks.json

There is also some tasks defined in Tasks.json, which can be executed by running F1 and writing Tasks: Run task and selecting one ofthe following:

  1. Build - Build Project
  2. Set Target to esp32
  3. Set Target to esp32s2
  4. Clean - Clean the project
  5. Flash - Flash the device
  6. Monitor - Start a monitor terminal
  7. OpenOCD - Start the openOCD server
  8. BuildFlash - Execute a build followed by a flash command.

Note that for OpenOCD tasks you need to define OPENOCD_SCRIPTS in your system environment variables with openocd scripts folder path.

Code of Conduct

This project and everyone participating in it is governed by the Code of Conduct. By participating, you are expected to uphold this code. Please report unacceptable behavior to vscode@espressif.com.

License

This extension is licensed under the Apache License 2.0. Please see the LICENSE file for additional copyright notices and terms.

Installation

  1. Download Visual Studio Code for macOS.
  2. Open the browser's download list and locate the downloaded archive.
  3. Select the 'magnifying glass' icon to open the archive in Finder.
  4. Drag Visual Studio Code.app to the Applications folder, making it available in the macOS Launchpad.
  5. Add VS Code to your Dock by right-clicking on the icon to bring up the context menu and choosing Options, Keep in Dock.

Launching from the command line

You can also run VS Code from the terminal by typing 'code' after adding it to the path:

  • Launch VS Code.
  • Open the Command Palette (Cmd+Shift+P) and type 'shell command' to find the Shell Command: Install 'code' command in PATH command.
  • Restart the terminal for the new $PATH value to take effect. You'll be able to type 'code .' in any folder to start editing files in that folder.

Note: If you still have the old code alias in your .bash_profile (or equivalent) from an early VS Code version, remove it and replace it by executing the Shell Command: Install 'code' command in PATH command.

Alternative manual instructions

Instead of running the command above, you can manually add VS Code to your path, to do so run the following commands:

Start a new terminal to pick up your .bash_profile changes.

Note: The leading slash is required to prevent $PATH from expanding during the concatenation. Remove the leading slash if you want to run the export command directly in a terminal.

Note: Since zsh became the default shell in macOS Catalina, run the following commands to add VS Code to your path:

Touch Bar support

Visual Studio Code In Mac

Out of the box VS Code adds actions to navigate in editor history as well as the full Debug tool bar to control the debugger on your Touch Bar:

Mojave privacy protections

After upgrading to macOS Mojave version, you may see dialogs saying 'Visual Studio Code would like to access your {calendar/contacts/photos}.' This is due to the new privacy protections in Mojave and is not specific to VS Code. The same dialogs may be displayed when running other applications as well. The dialog is shown once for each type of personal data and it is fine to choose Don't Allow since VS Code does not need access to those folders. You can read a more detailed explanation in this blog post.

Updates

VS Code ships monthly releases and supports auto-update when a new release is available. If you're prompted by VS Code, accept the newest update and it will get installed (you won't need to do anything else to get the latest bits).

Note: You can disable auto-update if you prefer to update VS Code on your own schedule.

Preferences menu

You can configure VS Code through settings, color themes, and custom keybindings available through the Code > Preferences menu group.

You may see mention of File > Preferences in documentation, which is the Preferences menu group location on Windows and Linux. On a macOS, the Preferences menu group is under Code, not File.

Next steps

See more results

Once you have installed VS Code, these topics will help you learn more about VS Code:

  • Additional Components - Learn how to install Git, Node.js, TypeScript, and tools like Yeoman.
  • User Interface - A quick orientation around VS Code.
  • User/Workspace Settings - Learn how to configure VS Code to your preferences settings.

Common questions

Why do I see 'Visual Studio Code would like access to your calendar.'

If you are running macOS Mojave version, you may see dialogs saying 'Visual Studio Code would like to access your {calendar/contacts/photos}.' This is due to the new privacy protections in Mojave discussed above. It is fine to choose Don't Allow since VS Code does not need access to those folders.

VS Code fails to update

If VS Code doesn't update once it restarts, it might be set under quarantine by macOS. Follow the steps in this issue for resolution.

'code .' Not Working In Command Line For Visual Studio Code ...

Does VS Code run on Mac M1 machines?

Macos - Indent/format Code In Visual Studio Code On MAC ...

Yes, VS Code supports macOS ARM64 builds that can run on Macs with the Apple M1 chip. You can install the Universal build, which includes both Intel and Apple Silicon builds, or one of the platform specific builds.