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. The premise is that Microsoft's Python extension is installed in VS Code. https://marketplace.visualstudio.com/items?itemName=ms-python.python
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.
From the setting UI, it looks like this.
By enabling this setting, the symbol search in the workspace will work.
The shortcut key for symbol search in the workspace is Ctrl + T
. From the command palette, it is Go to Symbole in Workspase
.
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.
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.
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.
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)
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.
Recommended Posts