Visual Studio Code installation and run it from Terminal on macOS
Background
Visual Studio Code is a free source-code editor made by Microsoft for Windows, Linux and macOS.
Features include support for debugging, syntax highlighting, intelligent code completion, snippets, code refactoring, and embedded Git. Users can change the theme, keyboard shortcuts, preferences, and install extensions that add additional functionality.
Installation
- Download Visual Studio Code for macOS directly.
- Go to your browser's lownloaded archive.
- Extract VSCode-darwin-stable.zip file
- Drag Visual Studio Code.cpp to the Applications folder, making it available in the macOS Launchpad.
Launching from the command line
You can type 'code .' in any folder to start editing files in that folder.
Notice: you will meet an error message: “code .” command is not working
Solution: You must add Visual Studio Code to the path first:
- Create bash_profile file if it doesn't exist in your system.
1
$ touch ~/.bash_profile
- Open this file, click 'i' to edit.
1
$ vi ~/.bash_profile
- Paste it as below, and type ':' + 'wq' to write & quit.<
1
export PATH="$PATH:/Applications/Visual Studio Code.app/Contents/Resources/app/bin"
- Preserve your current shell, if you miss it, you will repeat step2-step3 again when you reopen the terminal.
1
$ source ~/.bash_profile