Make it easy to switch current md doc between preview and edit mode#313428
Merged
mjbvz merged 1 commit intomicrosoft:mainfrom Apr 30, 2026
Merged
Make it easy to switch current md doc between preview and edit mode#313428mjbvz merged 1 commit intomicrosoft:mainfrom
mjbvz merged 1 commit intomicrosoft:mainfrom
Conversation
Fixes microsoft#312425 Also adds a toggle preview command
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds commands and UI contributions to quickly switch a Markdown document between the standard text editor and the Markdown preview custom editor, including a new toggle command and associated keybinding.
Changes:
- Set the custom editor preview tab icon for
vscode.markdown.preview.editor. - Add
markdown.reopenAsPreview,markdown.reopenAsSource, andmarkdown.togglePreviewcommands and register them. - Contribute new commands, editor title actions, and remap
Shift+Ctrl/Cmd+Vto the new toggle.
Show a summary per file
| File | Description |
|---|---|
| extensions/markdown-language-features/src/preview/preview.ts | Sets the webview icon for the Markdown preview custom editor. |
| extensions/markdown-language-features/src/commands/reopenAsPreview.ts | Adds commands to reopen as preview/source and a toggle command. |
| extensions/markdown-language-features/src/commands/index.ts | Registers the newly added commands. |
| extensions/markdown-language-features/package.nls.json | Adds localized titles for the new commands. |
| extensions/markdown-language-features/package.json | Adds command/menu contributions and updates the default preview keybinding to toggle. |
Copilot's findings
Comments suppressed due to low confidence (1)
extensions/markdown-language-features/package.json:372
- The
shift+ctrl/cmd+vkeybinding was changed to useresourceLangId. In keybinding contexts,resourceLangIdcan be set from non-editor focus (e.g. Explorer selection), which can make this shortcut active outside the editor and runmarkdown.togglePreviewagainst whatever editor is currently active. To keep the shortcut scoped to the active markdown editor/preview, consider usingeditorLangId =~ ...for the text editor case andactiveCustomEditorId == 'vscode.markdown.preview.editor'(and/oractiveWebviewPanelId == 'markdown.preview') for preview cases instead ofresourceLangId.
"command": "markdown.togglePreview",
"key": "shift+ctrl+v",
"mac": "shift+cmd+v",
"when": "resourceLangId =~ /^(markdown|prompt|instructions|chatagent|skill)$/ && !notebookEditorFocused"
}
- Files reviewed: 5/5 changed files
- Comments generated: 2
pwang347
approved these changes
Apr 30, 2026
|
Awesome!! Thank you Matt! |
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.
Fixes #312425
Fixes #301686
Also adds a toggle preview command