Revive symbol search in Python workspace with VS Code

Introduction

I can do a symbol search in a Python workspace with VS Code, but it has stopped working for some time. I was waiting for it to come back soon, but I didn't come back, so I looked it up. image.png The premise is that Microsoft's Python extension is installed in VS Code. image.png https://marketplace.visualstudio.com/items?itemName=ms-python.python

Conclusion earlier

The symbol search function in the workspace of the Python extension was simply disabled by default. If you enable it in the settings, it will work as before. Personally, I use it because it is effective and there are few problems. https://github.com/microsoft/vscode-python/issues/9046

It is OK if you set the setting item python.workspaceSymbols.enabled to true. image.png From the setting UI, it looks like this. image.png

By enabling this setting, the symbol search in the workspace will work. image.png

bonus

Shortcut key

The shortcut key for symbol search in the workspace is Ctrl + T. From the command palette, it is Go to Symbole in Workspase. image.png

Install ctags

Since the Python extension uses ctags to search for symbols in the workspace, it is necessary to install ctags separately to operate this function. For Windows, you can download the ctags executable file from GitHub and place it in a location where the path passes. Alternatively, you can specify the ctags path in the extension settings. image.png https://github.com/universal-ctags/ctags-win32/releases

The symbol search function will automatically generate a tags file in the .vscode directory in your workspace. (It seems that this function was turned off by default because of this specification.)

Microsoft Python Language Server

If you use Microsoft Python Language Server as the engine of IntelliSense, it seems that you can search for symbols in the workspace without using ctags. To switch to Microsoft Python Language Server, set python.jediEnabled to false in the Python extension settings. If true, a static analysis tool for Python called Jedi is used. Jedi is used by default. image.png https://pypi.org/project/jedi/

Personally, the standard library completion seems to work better with the Jedi, so I'm using the Jedi with the default settings.

Symbol search in file

You can search for symbols in a file with Go to Symbole in Editor of Ctrl + Shift + O. This does not use ctags even if you are using Jedi. (It works even if python.workspaceSymbols.enabled is false) image.png

I think it is good to use it properly with the search in the workspace. Also, if you enter : at the beginning, it will be sorted by category, which is convenient. image.png

Recommended Posts

Revive symbol search in Python workspace with VS Code
Use Python in Anaconda environment with VS Code
Python with VS Code (Windows 10)
Debug Python with VS Code
Allow real-time code checking in Python development with VS Code
VS Code settings for developing in Python with completion
Install python with mac vs code
Pass PYTHONPATH in 1 minute with VS Code
Python (Windows 10) Virtual Environment / Package with VS Code
Debug with VS Code using boost python numpy
Make your Python environment "easy" with VS Code
Build a python execution environment with VS Code
Linear search in Python
Binary search with python
Binary search with Python3
Binary search in Python (binary search)
Specific sample code for working with SQLite3 in Python
Try touching the micro: bit with VS Code + Python
Expose settings.json for efficient Python coding in VS Code
Get country code with python
Scraping with selenium in Python
Working with LibreOffice in Python
Scraping with chromedriver in python
Debugging with pdb in Python
Write Spigot in VS Code
Search for strings in Python
Working with sounds in Python
Scraping with Selenium in Python
Binary search in Python / C ++
Algorithm in Python (binary search)
Scraping with Tor in Python
Tweet with image in Python
Full bit search with Python
Combined with permutations in Python
Generate QR code in Python
Search engine work with python
Search twitter tweets with python
Character code learned in Python
Streamline web search with python
Document Python code with Doxygen
Settings when developing App Engine / Python apps with VS Code
Let's run jupyter natively supported by VS Code with python3.8
The story that Python stopped working with VS Code (Windows 10)
UpNext2 Development Record # 1 Build Python CI environment in VS Code
I want to be able to run Python in VS Code
Build a Python environment with WSL + Pyenv + Jupyter + VS Code
Number recognition in images with Python
Algorithm in Python (breadth-first search, bfs)
Write a binary search in Python
Testing with random numbers in Python
GOTO in Python with Sublime Text 3
[Python] Generate QR code in memory
Working with LibreOffice in Python: import
CSS parsing with cssutils in Python
Automatically format Python code in Vim
Learn search with Python # 2bit search, permutation search
Numer0n with items made in Python
Open UTF-8 with BOM in Python
Algorithm in Python (depth-first search, dfs)
Use rospy with virtualenv in Python3
Write selenium test code in python