This plugin provides seamless integration between Sublime Text and Ollama, allowing you to interact with AI models directly from your editor.
- 🤖 Direct integration with Ollama API
- 📝 Context-aware prompts using selected text or entire file
- 🔄 Streaming responses directly into your editor
- 📚 Template system for quick access to common prompts
- ⚡️ Keyboard shortcuts for quick access
- Install Ollama
- Have Sublime Text 3 or 4 installed
- Have Package Control installed in Sublime Text
- Open Command Palette (Cmd/Ctrl + Shift + P)
- Select "Package Control: Install Package"
- Search for "Ollama" and install
Open the command window (Cmd/Ctrl + Shift + P) then type:
Ollama: Select Modelto choose an Ollama modelOllama: Ask Promptto enter a promptOllama: Use Templateto use a saved templateOllama: Add Templateto save a new templateOllama: Remove Templateto delete a templateOllama: Settingsto configure the pluginOllama: Cancel Requestto cancel the current requestOllama: Show Historyto show the historyOllama: Clear Historyto clear the historyOllama: Toggle Output Panelto show/hide the output panelOllama: Add Contextto add files or folders as contextOllama: Remove Contextto remove previously added contexts
I recommend setting up keyboard shortcuts for these commands, e.g.
{ "keys": ["shift+super+t"], "command": "ollama_use_template" },
{ "keys": ["shift+super+h"], "command": "ollama_show_history" },
{ "keys": ["super+shift+o"], "command": "ollama_ask_any", "args": { "prompt": null } },
{ "keys": ["ctrl+shift+c"], "command": "ollama_cancel_request", "args": {} },
{ "keys": ["super+shift+k"], "command": "ollama_toggle_output_panel", "args": {} },
{ "keys": ["super+shift+m"], "command": "ollama_select_model", "args": {} },
{ "keys": ["super+shift+c"], "command": "ollama_add_context", "args": {} },
{ "keys": ["super+ctrl+c"], "command": "ollama_remove_context", "args": {} }- Use
Ollama: Add Contextto add files or folders as context - Supports wildcards (e.g.,
./src/**.pyfor all Python files in src and subdirectories) - Use
Ollama: Remove Contextto remove previously added contexts - Only text-based file types are included (configurable in settings)
- Context files are automatically included in all queries
Example context patterns:
./src/**.py- all Python files in src and subdirectories./docs/*.md- all Markdown files in docs directory./config.json- single file./templates/- all supported files in templates directory
The output panel provides a dedicated space for viewing AI responses without modifying your current file. You can:
- Toggle it with
Cmd/Ctrl + Shift + K - Use it through Command Palette:
Ollama: Toggle Output Panel - Keep it open while working with multiple prompts
- Scroll through longer responses easily
- Select text in editor (optional)
- Use any of the prompt commands
- If text is selected, it will be used as context
- If no text is selected, the entire file content will be used
Templates allow you to save frequently used prompts for quick access.
To add a template:
- Open Command Palette
- Select "Ollama: Add Template"
- Enter template title
- Enter template prompt
To use a template:
- Open Command Palette
- Select "Ollama: Use Template"
- Choose template from list
- Edit prompt if needed
- Press Enter to execute
Default settings can be modified through: Preferences > Package Settings > Ollama > Settings
{
"ollamaUrl": "http://localhost:11434",
"systemPrompt": "You are a helpful assistant.",
"selected_model": "",
"templates": [
{
"title": "Summarize",
"prompt": "Summarize the text.",
"model": "phi4:latest" // model is optional
},
{
"title": "Translate",
"prompt": "Translate the following text to French."
}
],
"history": [] // Stores last 50 prompts automatically
}ollamaUrl: URL where Ollama is runningsystemPrompt: Default system prompt for all requestsselected_model: Currently selected Ollama modeltemplates: Array of saved templatestitle: Template name shown in selection menuprompt: The prompt textmodel: (Optional) Specific model for this template
history: Array of previous prompts (managed automatically)
- Sublime Text 3 or 4
- Ollama installed and running
requestsPython package (installed automatically)
-
No models available
- Ensure Ollama is running (
ollama serve) - Check the Ollama URL in settings
- Verify you have at least one model pulled (
ollama pull modelname)
- Ensure Ollama is running (
-
Connection errors
- Check if Ollama is running
- Verify the URL in settings
- Check console for detailed error messages
-
Slow responses
- Consider using a smaller/faster model
- Check your system resources
- Verify network connection
MIT License
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a new Pull Request