More tips for using VS Code with EDM

This article is a supplement to  "Using Visual Studio Code (VS Code) as an IDE with the Enthought Deployment Manager (EDM)" . Here we offer some optional productivity tips.

Using a VS Code single folder project / workspace

You can accomplish a lot using VS Code as a file-by-file text editor, using the File menu to open each file individually.

If you will be working on a collection of related files, and especially if you will be switching between different projects, VS Code "workspaces" can be useful. The simplest way to do this is with a "single folder project", which you can create by:

  • On the VS Code home page, "Open Folder"
  • On the Enthought Tools for Visual Studio Code panel, activate your Enthought Python environment (see "Activate" in the main article referenced above)
  • Open one or more files within that folder.

Launching VS Code from a command line in macOS Terminal

It can be useful to launch VS Code from a command line. This is not enabled by default on macOS. You can enable this either by following these instructions from Microsoft, or by adding a "soft link" to VS Code in a directory that is already on your PATH. To add such a link, copy/paste the following long command into a Terminal, then enter your macOS login password when prompted:

sudo ln -s "/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code" /usr/local/bin/code

Whichever way you enable it, entering the command:
code (optionally followed by the name of a file to edit) 
in a Terminal / shell, will start the VS Code editor, or switch to it if already open.

Universal Ctags (intermediate difficulty)

To make it easier to navigate through complex code, you can install the Universal Ctags software. If Ctags is installed and available on the system path, the Python plugin will automatically use it to generate the tags file needed to navigate through your code to class and function definitions. There is no need for a separate Ctags plugin for Python.

Installation

Windows users can download the latest compiled release from Universal Ctags. It will be a zip file that simply has to be unzipped into a directory. We recommend that you unzip it into your user  Documents\ctags directory. Afterwards, make sure that this directory is listed in  your Windows environment variable PATH (or see alternative method, below).

Installation notes for MacOS using brew can be found on Homebrew Tap for Universal Ctags.

Linux users will need to clone the Git repository and compile as documented on Universal Ctags.

If you can't easily modify your PATH environment variable, another way to make Ctags available for Python in VS Code is to edit your settings.json file (described above in "About Microsoft's Python Extension for VS Code.")

In Windows, add these lines into an appropriate position in settings.json (assuming that you unzipped ctags into the suggested directory):

    "python.workspaceSymbols.enabled": true,
"python.workspaceSymbols.ctagsPath": "${env:USERPROFILE}\\Documents\\ctags\\ctags.exe",

 

Preparation

To use Ctags in VS Code, you must be working in a VS Code "workspace" (see above). 

Usage

Select a class or function name in your code.

Type Ctrl-T. A list of Python objects drops down from the top of the VS Code editor; select one of these to go to that object's definition.

Code Runner extension

Enthought Tools for Visual Studio Code is not compatible with the Code Runner extension for VS Code. If you have this extension installed, please disable it when using Enthought Tools for Visual Studio Code. (Code Runner changes the appearance and behavior of the Run button; it becomes unable to find Enthought Python. Its icon on the editor bar is a pinkish circle / head.)

Other VS Code Extensions

There are very many VS Code extensions, with overlapping functionalities. Here are some Python-specific extensions which you might consider:

autoDocstring
Bracket Pair Colorizer 2
CobiSymbolOutline
Language-Cython
Markdown All in One
Projects+
reStructuredText
Rewrap
Settings Sync

Please do not enter support requests in article comments

Please use article comments for suggestions to improve the article. For individual support requests, please follow these guidelines.

 

 

Have more questions? Submit a request

Comments

Powered by Zendesk