How to Preview Markdown in VS Code: Shortcuts & Settings
VS Code’s built-in Markdown preview does more than most people use: synced scrolling, math, Mermaid diagrams, link validation, and image pasting are all included. This guide covers how to open the preview, the settings worth changing, how to get closer to GitHub’s rendering, and how to fix the usual problems. Everything was checked against VS Code 1.141.
Press Ctrl+Shift+V (⇧⌘V on Mac) to switch the current .md file to its preview, or Ctrl+K then V (⌘K V) to open the preview side by side. If nothing happens, the file’s language mode isn’t Markdown — change it in the bottom-right corner of the status bar.
Open the preview: shortcuts and commands
You can also click the preview icon in the editor’s title bar, or right-click the file’s tab and choose Open Preview. Commands without a default shortcut are in the Command Palette (Ctrl+Shift+P / ⇧⌘P) — you can bind your own keys to them in Keyboard Shortcuts.
| What it does | Windows / Linux | macOS | Command Palette |
|---|---|---|---|
| Toggle preview (replace the editor with the preview, and back) | Ctrl+Shift+V | ⇧⌘V | Markdown: Toggle Preview |
| Open preview to the side (split view) | Ctrl+K V | ⌘K V | Markdown: Open Preview to the Side |
| Open a preview locked to this file, to the side | — | — | Markdown: Open Locked Preview to the Side |
| Lock or unlock the current preview | — | — | Markdown: Toggle Preview Locking |
| Jump from the preview back to the source file | — | — | Markdown: Open Source File |
| Re-render the preview | — | — | Markdown: Refresh Preview |
| Allow or block images and scripts in the preview | — | — | Markdown: Change Preview Security Settings |
Follow the active file, or lock the preview
By default a preview is dynamic: when you switch to another Markdown file, the preview switches with you. When you want a preview to stay on one document — for example while editing a file that links to it — open it with Markdown: Open Locked Preview to the Side, or run Markdown: Toggle Preview Locking while the preview tab is active. Locked previews show [Preview] in their tab title.
Open .md files (and diffs) in preview by default
If you mostly read Markdown, make the preview the default editor for .md files. This also renders Markdown diffs from the Source Control view as a formatted, highlighted preview instead of raw text:
"workbench.editorAssociations": {
"*.md": "vscode.markdown.preview.editor"
}To use the rendered view only for diffs, put the same mapping in workbench.diffEditorAssociations instead. For a one-off, run View: Reopen Editor With… and pick Markdown Preview.
Scroll sync and navigation settings
These are the preview settings and their defaults in VS Code 1.141. The two most useful changes are turning on doubleClickToSwitchToEditor (off by default) and markEditorSelection.
| Setting | Default | What it does |
|---|---|---|
| markdown.preview.scrollPreviewWithEditor | true | Scrolling the editor scrolls the preview. |
| markdown.preview.scrollEditorWithPreview | true | Scrolling the preview scrolls the editor. |
| markdown.preview.markEditorSelection | false | Marks the line your cursor is on inside the preview. |
| markdown.preview.doubleClickToSwitchToEditor | false | Double-click an element in the preview to jump to its line in the editor. |
| markdown.preview.openMarkdownLinks | "inPreview" | Links to other .md files open in the preview (or "inEditor"). |
| markdown.preview.breaks | false | Turn single newlines into <br>. Keep false to match how GitHub renders .md files. |
| markdown.preview.linkify | true | Turn plain URLs into links. |
| markdown.preview.typographer | false | Smart quotes and typographic replacements. |
| markdown.preview.frontMatter | "table" | How YAML front matter at the top of a file is shown. |
Math and Mermaid diagrams (built in)
Math is rendered with KaTeX: $...$ for inline and $$...$$ for blocks. It’s on by default (markdown.math.enabled). You can define shortcuts for commands you use often with markdown.math.macros:
"markdown.math.macros": {
"\\RR": "\\mathbb{R}"
}Mermaid diagrams in ```mermaid blocks render in the built-in preview since VS Code 1.121 — no extension needed. Hold Alt (Option) and drag to pan or scroll to zoom, or use the controls that appear on hover. The diagram theme follows VS Code by default; change it with markdown-mermaid.lightModeTheme and markdown-mermaid.darkModeTheme. Test tricky diagrams in our Mermaid previewer and formulas in the LaTeX previewer.
Make the preview look like GitHub
VS Code’s own documentation is clear that the preview targets CommonMark (via markdown-it), not GitHub Flavored Markdown. In practice that means:
Tables, strikethrough, fenced code with highlighting, math, Mermaid, front matter.
GitHub styling, task-list checkboxes, footnotes, :emoji: shortcodes, and [!NOTE] alerts.
Matt Bierner’s GitHub Markdown Preview pack (bierner.github-markdown-preview) installs GitHub styling plus emoji, checkboxes, and footnotes. It changes how the preview looks, not how VS Code parses Markdown, so for GitHub-only syntax — alerts, ```math blocks, and the exact README rendering — check the file in our GitHub Markdown Preview or on github.com. If a README renders differently on GitHub, see why GitHub Markdown isn’t rendering.
Built-in features that save time
- Jump to a heading. Ctrl+Shift+O (⇧⌘O) lists the headings in the current file; Ctrl+T (⌘T) searches headings across the whole workspace. The Outline view in the Explorer shows the heading tree.
- Path completions. Type ./ or / inside a link or image to get file suggestions, or # to link to a heading. Type ## to link to a heading in another file.
- Paste and drop images. Paste an image, or drag a file from the Explorer while holding Shift, and VS Code inserts the Markdown link — copying files from outside the workspace into it. Choose where they go with markdown.copyFiles.destination.
- Link validation. Off by default. With "markdown.validate.enabled": true, VS Code warns about links to missing files and headings (local links only).
- Rename headings safely. Press F2 on a heading to rename it and update every link that points to it — even in other files.
- Update links when files move. Set markdown.updateLinksOnFileMove.enabled to "prompt" or "always" (default "never") to fix links when you rename or move files.
Fonts and custom CSS
Adjust the basics with markdown.preview.fontFamily, markdown.preview.fontSize (default 14) and markdown.preview.lineHeight (default 1.6). For full control, point markdown.styles at a stylesheet — an https URL or a path relative to the folder open in the Explorer:
"markdown.styles": ["styles/markdown-preview.css"]
Dark mode and printing
The built-in preview follows your color theme: switch VS Code to a dark theme (Preferences: Color Theme) and the preview turns dark too. With the GitHub styling extension installed, choose its theme explicitly with markdown-preview-github-styles.colorTheme — for example a single light theme for screenshots — and pick from GitHub’s light, dark, dimmed, high-contrast, and color-blind themes.
VS Code has no print command for the preview. To print, export to PDF with an extension (below) and print that, or paste the file into our online previewer and use Export → PDF, which opens your browser’s print dialog with GitHub-style formatting.
Export to PDF or HTML
VS Code doesn’t export Markdown on its own. Your options: the Markdown PDF extension (PDF, HTML, PNG, JPEG), Markdown Preview Enhanced (its own preview with export and presentation modes), or — without installing anything — paste the file into our online previewer and use Export for HTML, a print-ready PDF, or PNG.
Cursor, Windsurf, Antigravity & VSCodium
Cursor, Windsurf, and Google Antigravity are forks of VS Code, and VSCodium is built from VS Code’s source. They inherit its built-in Markdown preview, so everything in this guide applies: open the Command Palette and run Markdown: Open Preview to the Side. The default shortcuts (Ctrl+Shift+V, Ctrl+K V) usually carry over, but forks can rebind keys — if a shortcut does something else, search “Markdown: Open Preview” in Keyboard Shortcuts to see or set the binding. Features added in recent VS Code releases (such as built-in Mermaid) appear in a fork only after it updates to that VS Code version. Using Visual Studio, a JetBrains IDE, Zed, Sublime Text, or Neovim instead? See how to preview Markdown in any editor.
Recommended settings.json
Open it with Preferences: Open User Settings (JSON) from the Command Palette. Every key below exists in VS Code 1.141; settings already at a sensible default are left out.
{
// Preview behavior
"markdown.preview.doubleClickToSwitchToEditor": true,
"markdown.preview.markEditorSelection": true,
// Catch broken links to files and headings while you type
"markdown.validate.enabled": true,
// Keep links working when you move or rename files
"markdown.updateLinksOnFileMove.enabled": "prompt",
// Put pasted or dropped images in a folder next to the document
"markdown.copyFiles.destination": {
"**/*.md": "images/${documentBaseName}/"
},
// Keep trailing double spaces (hard line breaks) in Markdown files
"[markdown]": {
"files.trimTrailingWhitespace": false
}
}Extensions worth installing
Install by ID: open the Extensions view (Ctrl+Shift+X) and paste the ID, or run code --install-extension <id>. IDs and publishers were checked on the Visual Studio Marketplace.
GitHub Markdown Preview (extension pack)
bierner.github-markdown-previewby Matt Bierner
Bundles GitHub styling, :emoji: shortcodes, task-list checkboxes, and footnotes for the built-in preview.
Install it if: Your files are destined for GitHub and you want the preview to look like it.
markdownlint
DavidAnson.vscode-markdownlintby David Anson
Lints Markdown style and structure (heading levels, list markers, line length, and more) as you type.
Install it if: You maintain docs with several contributors and want consistent Markdown.
Markdown All in One
yzhang.markdown-all-in-oneby Yu Zhang
Keyboard shortcuts for formatting, list continuation, table formatting, and an auto-updating table of contents.
Install it if: You write a lot of Markdown by hand and want editor shortcuts.
Markdown PDF
yzane.markdown-pdfby yzane
Exports Markdown to PDF, HTML, PNG, or JPEG from the Command Palette or the editor's context menu.
Install it if: You need a PDF from VS Code without changing your preview.
Markdown Preview Enhanced
shd101wyy.markdown-preview-enhancedby Yiyi Wang
A separate, feature-rich preview with PDF/HTML export, presentation mode, PlantUML, and code chunks.
Install it if: You want one tool for advanced documents and exports.
Using a VS Code version older than 1.121? Add bierner.markdown-mermaid for Mermaid diagrams.
Markdown preview not working? Troubleshooting
Ctrl+Shift+V does nothing
Why: The Markdown preview shortcuts only fire when the active file's language mode is Markdown and the editor has focus (not the terminal or a notebook).
Fix: Check the language indicator in the bottom-right of the status bar. If it says Plain Text, click it and choose Markdown — common for files without a .md extension. Then click into the editor and try again.
Images do not appear in the preview
Why: The default "Strict" preview security only loads content over https and blocks http images. Relative paths also have to be correct from the Markdown file's folder.
Fix: Use an https URL or a correct relative path (type ./ inside the parentheses for path completions). If you trust the workspace, run "Markdown: Change Preview Security Settings" and choose "Allow insecure content".
The preview shows a different file than the one you are editing
Why: The preview is locked. Locked previews show [Preview] in their tab title and do not follow the active editor.
Fix: Run "Markdown: Toggle Preview Locking" while the preview tab is active, or close it and press Ctrl+K V again.
Mermaid code blocks show as plain code
Why: Built-in Mermaid rendering requires VS Code 1.121 or later, and the code block must be tagged mermaid. A syntax error shows an error instead of a diagram.
Fix: Update VS Code (Help → Check for Updates), check the language tag, and validate the diagram in our Mermaid previewer. On older versions, install bierner.markdown-mermaid.
Math shows as $...$ text
Why: Math rendering is disabled (markdown.math.enabled is false), the delimiters are not $ / $$, or KaTeX does not support a command you used.
Fix: Set "markdown.math.enabled": true and use $...$ or $$...$$. VS Code does not render GitHub's ```math blocks or $`...`$ syntax.
Line breaks in the preview don't match your file
Why: A single newline is a space in Markdown, and VS Code may be trimming the two trailing spaces you used for a hard break.
Fix: End the line with a backslash instead, or disable files.trimTrailingWhitespace for [markdown] as shown in the settings below.
Alerts, task lists, or footnotes render as plain text
Why: VS Code's preview targets CommonMark; these GitHub features are not built in.
Fix: Install the GitHub Markdown Preview extension pack for task lists and footnotes, and check GitHub-specific syntax such as alerts in our GitHub Markdown Preview.
The preview is blank or stuck
Why: A preview extension failed to load, or the webview process crashed.
Fix: Run "Developer: Reload Window". If it persists, run "Help: Start Extension Bisect" to find the extension causing it.
Shortcuts, command names, and every setting default in this guide were read from the source of VS Code 1.141.0 — the package.json files of its built-in Markdown, math, and Mermaid extensions — rather than copied from older articles. That’s how we caught, for example, that double-click-to-edit is now off by default and that Mermaid has been built in since 1.121.
Feature descriptions follow the official VS Code Markdown documentation, and extension IDs and publishers were checked against the Visual Studio Marketplace on the date shown above. Spot something that changed in a newer release? Email hello@markdownpreview.net.
Frequently asked questions
How do I preview Markdown in Cursor or Windsurf?
How do I get a dark Markdown preview in VS Code?
What is the shortcut for Markdown preview in VS Code?
Does VS Code support GitHub Flavored Markdown?
Can VS Code render Mermaid diagrams without an extension?
How do I export Markdown to PDF from VS Code?
How do I make the preview look like GitHub?
Can I preview Markdown in VS Code without installing it?
Sources
- VS Code docs — Markdown and Visual Studio Code — preview, locking, sync, math, Mermaid, link validation, security
- VS Code 1.141 source — markdown-language-features/package.json — default keybindings, commands, and setting defaults
- VS Code 1.141 source — markdown-math/package.json — markdown.math settings
- VS Code 1.141 source — mermaid-markdown-features — built-in Mermaid support (first present in 1.121.0)
- Visual Studio Marketplace — extension IDs and publishers
- Markdown Preview Github Styling — README — theme settings
- Visual Studio Magazine — Antigravity, Cursor and Windsurf compared — these editors are VS Code forks