How to call VS Code Editor from terminal / command line

前端 未结 21 1483
别那么骄傲
别那么骄傲 2020-12-04 06:22

The question says it all.

How can I open VS Code editor from

  • windows cmd
  • linux and mac terminal

e.g. for notepad++ I write

21条回答
  •  不知归路
    2020-12-04 07:03

    Per the docs:

    Mac OS X

    1. Download Visual Studio Code for Mac OS X.
    2. Double-click on VSCode-osx.zip to expand the contents.
    3. Drag Visual Studio Code.app to the Applications folder, making it available in the Launchpad.
    4. Add VS Code to your Dock by right-clicking on the icon and choosing Options, Keep in Dock.

    Tip: If you want to run VS Code from the terminal, append the following to your ~/.bash_profile file (~/.zshrc in case you use zsh).

    code () { VSCODE_CWD="$PWD" open -n -b "com.microsoft.VSCode" --args $* ;}
    

    Now, you can simply type code . in any folder to start editing files in that folder.

    Tip: You can also add it to VS Code Insiders build by changing "com.microsoft.VSCodeInsiders". Also if you don't to type the whole word code, just change it to c.

    Linux

    1. Download Visual Studio Code for Linux.
    2. Make a new folder and extract VSCode-linux-x64.zip inside that folder.
    3. Double click on Code to run Visual Studio Code.

    Tip: If you want to run VS Code from the terminal, create the following link substituting /path/to/vscode/Code with the absolute path to the Code executable

    sudo ln -s /path/to/vscode/Code /usr/local/bin/code
    

    Now, you can simply type code . in any folder to start editing files in that folder.

提交回复
热议问题