Conversation
CherryWorm
pushed a commit
to CherryWorm/zed
that referenced
this pull request
Dec 16, 2025
Closes zed-industries#20036 This introduces new action `editor: insert snippet`. It supports three modes: ``` ["editor::InsertSnippet", {"name": "snippet_name"}] ["editor::InsertSnippet", {"language": "language_name", "name": "snippet_name"}] ["editor::InsertSnippet", {"snippet": "snippet with $1 tab stops"}] ``` ## Example usage ### `keymap.json` ```json { "context": "Editor", "bindings": { // named global snippet "cmd-k cmd-r": ["editor::InsertSnippet", {"name": "all rights reserved"}], // named language-specific snippet "cmd-k cmd-p": ["editor::InsertSnippet", {"language": "rust", "name": "debug-print a value"}], // inline snippet "cmd-k cmd-e": ["editor::InsertSnippet", {"snippet": "println!(\"This snippet has multiple lines.\")\nprintln!(\"It belongs to $1 and is very $2.\")"}], }, }, ``` ### `~/.config/zed/snippets/rust.json` ```json { "debug-print a value": { "body": "println!(\"$1 = {:?}\", $1)", }, } ``` ### `~/.config/zed/snippets/snippets.json` ```json { "all rights reserved": { "body": "Copyright © ${1:2025} ${2:your name}. All rights reserved.", }, } ``` ## Future extensions - Support multiline inline snippets using an array of strings using something similar to `ListOrDirect` in `snippet_provider::format::VsCodeSnippet` - When called with no arguments, open a modal to select a snippet to insert ## Release notes Release Notes: - Added `editor::InsertSnippet` action
someone13574
added a commit
to someone13574/zed
that referenced
this pull request
Dec 16, 2025
Closes zed-industries#20036 This introduces new action `editor: insert snippet`. It supports three modes: ``` ["editor::InsertSnippet", {"name": "snippet_name"}] ["editor::InsertSnippet", {"language": "language_name", "name": "snippet_name"}] ["editor::InsertSnippet", {"snippet": "snippet with $1 tab stops"}] ``` ```json { "context": "Editor", "bindings": { // named global snippet "cmd-k cmd-r": ["editor::InsertSnippet", {"name": "all rights reserved"}], // named language-specific snippet "cmd-k cmd-p": ["editor::InsertSnippet", {"language": "rust", "name": "debug-print a value"}], // inline snippet "cmd-k cmd-e": ["editor::InsertSnippet", {"snippet": "println!(\"This snippet has multiple lines.\")\nprintln!(\"It belongs to $1 and is very $2.\")"}], }, }, ``` ```json { "debug-print a value": { "body": "println!(\"$1 = {:?}\", $1)", }, } ``` ```json { "all rights reserved": { "body": "Copyright © ${1:2025} ${2:your name}. All rights reserved.", }, } ``` - Support multiline inline snippets using an array of strings using something similar to `ListOrDirect` in `snippet_provider::format::VsCodeSnippet` - When called with no arguments, open a modal to select a snippet to insert Release Notes: - Added `editor::InsertSnippet` action
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #20036
This introduces new action
editor: insert snippet. It supports three modes:Example usage
keymap.json{ "context": "Editor", "bindings": { // named global snippet "cmd-k cmd-r": ["editor::InsertSnippet", {"name": "all rights reserved"}], // named language-specific snippet "cmd-k cmd-p": ["editor::InsertSnippet", {"language": "rust", "name": "debug-print a value"}], // inline snippet "cmd-k cmd-e": ["editor::InsertSnippet", {"snippet": "println!(\"This snippet has multiple lines.\")\nprintln!(\"It belongs to $1 and is very $2.\")"}], }, },~/.config/zed/snippets/rust.json{ "debug-print a value": { "body": "println!(\"$1 = {:?}\", $1)", }, }~/.config/zed/snippets/snippets.json{ "all rights reserved": { "body": "Copyright © ${1:2025} ${2:your name}. All rights reserved.", }, }Future extensions
ListOrDirectinsnippet_provider::format::VsCodeSnippetRelease notes
Release Notes:
editor::InsertSnippetaction