Quickly Navigating Python Libraries With ctags

I also have to admit that I am definitely not an expert at VS Code, so suggestions/comments would be greatly appreciated.

Okay lets get started!First, if you already do not have Python, install Python.

I strongly recommend downloading Python through Anaconda.

Second, download and install Visual Studio Code.

Again, it is completely free and is compatible with either Windows, Linux or Mac, so this should be easy enough!Next, open Visual Studio Code.

First, you are going to have to select Python as your interpreter.

To do this type Ctrl+Shift+P and start typing “Python: Select Interpreter.

” Then select the Python version and environment you want to load.

Again, I often use fastai so I select the Python environment for fastai.

If “Python: Select Interpreter” is not appearing, this means that Python is not installed on your system.

This is an easy fix, so just follow the instructions here.

4.

Now open the folder that contains the Python library that you want to easily explore (e.

g.

, fastai).

When you do this, VS Code is going to create a directory there labeled .

vscode.

This directory contains a JSON file labeled settings.

json.

Open up the settings.

json file in VS Code (or any text editor).

We will edit this file in a couple of steps.

5.

Next, you will need to download the ctags package.

Ctags generates an index (or tag) file of names found in source and headers files.

This is how we can quickly search through our code, by creating these tags.

You can download them from this GitHub site.

If you are using Windows, you can click on releases, select the most recent version, and select the zip file to download.

Unzip this zip file wherever you like, but I usually just put it in the .

vscode directory.

6.

Remember the settings.

json file?.You are going to need to edit it now.

Already in the JSON should be a line that specifies the path to the Python executable.

Now you are going to need to add a line specifying the path to the ctags.

exe file.

Create a new line and add the following line of code (replace LIBRARY_PATH with the path to your Python library or wherever you chose to place the ctags.

exe file):"python.

workspaceSymbols.

ctagsPath": "LIBRARY_PATH.

vscodectags-2018-11-06_0f27679c-x64ctags.

exe"Your settings.

json file should look like this:7.

Next, generate the tags!.VS Code makes this really easy.

All you have to do is type Ctrl + t.

This should create a tags file, which contains all of the tags.

If this does not work, open up the Terminal is VS Code, go to the Output tab, type Ctrl + t again, and see what the output says.

8.

You can now navigate tags by typing Ctrl + t and typing names of classes and functions you would like to search.

Easy enough!What else can I do with VS Code?The tags have been created and now are ready to be used.

There are many other useful shortcuts in VS Code.

Here are a few that I am shamelessly stealing from the fast.

ai course:Command palette: Ctrl-shift-pGo to symbol: Ctril-tFind references: Shift-F12Go to definition: F12Go back: Alt-leftGo forward: Alt-rightHide sidebar: Ctrl-bZen mode: Ctrl-k,zI hope you found this useful and comments/suggestions are more than welcome!.

. More details

Leave a Reply