Of course! This is a classic and powerful combination for Python development in Sublime Text. Here’s a comprehensive guide covering everything from the basics to advanced configuration.

What is Jedi?
First, it's important to understand what Jedi is.
- Jedi is a static analysis tool for Python. It's not just an auto-completer; it's a full-fledged code intelligence engine.
- It powers features like autocompletion, go-to-definition, find all references, and symbol lookup (e.g., viewing function signatures).
- It's designed to be fast and accurate, making it the preferred backend for many popular Python IDEs and editors, including Sublime Text (via a plugin).
The Core Workflow: Sublime Text + Jedi
The standard way to get Jedi working in Sublime Text is through the LSP (Language Server Protocol) ecosystem. This is a modern, robust approach that centralizes language intelligence for many different languages.
Here’s the step-by-step process:
Step 1: Install the Prerequisites
- Install Sublime Text: Make sure you have a recent version of Sublime Text (ideally 4 or newer).
- Install Package Control: This is the essential package manager for Sublime Text. If you don't have it, follow the official instructions: https://packagecontrol.io/installation
Step 2: Install the LSP Package
The LSP package is the bridge between Sublime Text and the language servers (like Jedi).

- Open Sublime Text.
- Press
Cmd+Shift+P(macOS) orCtrl+Shift+P(Windows/Linux) to open the Command Palette. - Type
Install Packageand select it. - Type
LSPand install the package bysublimelsp.
Step 3: Install the Jedi Language Server
Now, we'll tell the LSP package to use Jedi for Python files.
- Open the Command Palette (
Cmd+Shift+P/Ctrl+Shift+P). - Type
LSP: Install Serverand select it. - A list of available servers will appear. Type
jediand selectJedi Language Server. - Sublime Text will automatically download and configure the server for you.
Step 4: Configure Python to Use Jedi
Sublime Text needs to know which Python interpreter to use for the Jedi server to analyze your code.
-
Open the Command Palette.
-
Type
LSP: Select LSP Serverand select it.
(图片来源网络,侵删) -
You will see a list of installed servers. Find
Jediand select it. -
A new menu will appear. Select
python.executable. -
Sublime Text will now try to find your Python executable. It will likely find your system Python. If you are using a virtual environment, you need to manually point it to the
pythonexecutable inside that environment'sbin/(macOS/Linux) orScripts/(Windows) folder.-
How to set it for a specific project (Recommended):
- In your Sublime Text project, create a file named
sublime-projectif it doesn't exist. - Add the following configuration, replacing
/path/to/your/venv/bin/pythonwith the actual path to your virtual environment's Python.
{ "folders": [ { "path": "/path/to/your/project/folder" } ], "settings": { "LSP": { "jedi": { "python": "/path/to/your/venv/bin/python" } } } }Save the file. Now, whenever you have this project open, LSP will use the Python interpreter from your virtual environment.
- In your Sublime Text project, create a file named
-
How to Use Jedi in Sublime Text (The Features)
Once configured, you can use powerful Jedi features. Most are triggered via the Command Palette or keybindings.
| Feature | How to Trigger | What it Does |
|---|---|---|
| Autocompletion | Tab or Ctrl+Space |
As you type, Jedi suggests variables, functions, classes, and keywords from your project and installed libraries. |
| Go to Definition | F12 or Ctrl+Click on a symbol |
Jumps you directly to the line where a function, class, or variable is defined. |
| Go to Definition (in a new tab) | Ctrl+K, Ctrl+B (default keybinding for "Find in Project" but can be remapped or accessed via Command Palette) |
Opens the definition in a new tab, which is useful for keeping your current context. |
| Find All References | Shift+F12 |
Finds all the places in your codebase where a particular symbol (like a function name) is used. |
| Hover for Documentation | Ctrl+K, Ctrl+D (default) or just Ctrl+Hover |
Shows you a pop-up with the docstring (documentation) for the function or class your cursor is on. |
| Symbols in Current File | Ctrl+R |
Shows a list of all classes and functions in the current file, allowing you to quickly navigate to one. |
| Workspace Symbols | Ctrl+Shift+R |
Searches for symbols (classes, functions, etc.) across your entire project. |
Troubleshooting and Advanced Configuration
My autocompletion is slow or doesn't work.
- Check your Python path: This is the #1 issue. Ensure your
python.executablesetting correctly points to the Python interpreter of your virtual environment. If it points to a system Python without your project's packages, Jedi won't know about them. - Disable other linters: If you have other linters like
PylintorFlake8running via other packages, they can conflict with Jedi or slow things down. Try disabling them to see if performance improves. - Check for syntax errors: Jedi can have trouble analyzing a file if it has major syntax errors. Fixing these can restore functionality.
I want to customize keybindings.
You can override default keybindings by adding them to your User Key Bindings file (Preferences > Key Bindings - User).
Example: To change "Go to Definition" to F2:
[
{ "keys": ["f2"], "command": "lsp_symbol_definition" }
]
You can find the command names by looking at the LSP package's documentation or by using the Ctrl+Shift+P menu to see available commands.
How do I see logs or debug?
If Jedi is misbehaving, the logs are your best friend.
- Open the Sublime Text console:
View > Show Consoleor `Ctrl+`` (backtick). - You can also find more detailed logs in the output panel. Open the Command Palette and run
LSP: Show Log. This will show you communication between Sublime Text and the Jedi server, which is great for spotting errors.
Alternative (but not recommended) Method: SublimeJedi
You might find an old package called SublimeJedi. Do not use it.
- It's unmaintained: It hasn't been updated in years and is incompatible with modern Sublime Text versions.
- LSP is the standard: The
LSP+Jedi Language Servercombination is the modern, actively maintained, and far more robust way to get Jedi support in Sublime Text. It provides a consistent experience across all languages.
