Developer Workflow Guide

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.

Updated 11 min readBy the MarkdownPreview.net team
Quick answer

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 doesWindows / LinuxmacOSCommand Palette
Toggle preview (replace the editor with the preview, and back)Ctrl+Shift+V⇧⌘VMarkdown: Toggle Preview
Open preview to the side (split view)Ctrl+K V⌘K VMarkdown: 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:

settings.json
"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.

SettingDefaultWhat it does
markdown.preview.scrollPreviewWithEditortrueScrolling the editor scrolls the preview.
markdown.preview.scrollEditorWithPreviewtrueScrolling the preview scrolls the editor.
markdown.preview.markEditorSelectionfalseMarks the line your cursor is on inside the preview.
markdown.preview.doubleClickToSwitchToEditorfalseDouble-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.breaksfalseTurn single newlines into <br>. Keep false to match how GitHub renders .md files.
markdown.preview.linkifytrueTurn plain URLs into links.
markdown.preview.typographerfalseSmart 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:

settings.json
"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:

Works out of the box

Tables, strikethrough, fenced code with highlighting, math, Mermaid, front matter.

Needs an extension (or GitHub)

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:

settings.json
"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.

settings.json
{
  // 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-preview

by 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-markdownlint

by 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-one

by 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-pdf

by 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-enhanced

by 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.

How we verified this guide

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?

Cursor and Windsurf are built on VS Code, so they include the same Markdown preview. Run "Markdown: Open Preview to the Side" from the Command Palette, or try Ctrl+K V / Ctrl+Shift+V (⌘K V / ⇧⌘V on Mac). If a shortcut is taken by another feature, assign one in Keyboard Shortcuts.

How do I get a dark Markdown preview in VS Code?

The preview follows your VS Code color theme, so choosing a dark theme makes it dark. With the "Markdown Preview Github Styling" extension, set markdown-preview-github-styles.colorTheme to control it separately.

What is the shortcut for Markdown preview in VS Code?

Ctrl+Shift+V (⇧⌘V on macOS) toggles the current Markdown file between source and preview. Ctrl+K then V (⌘K V on macOS) opens the preview side by side with the editor. Both work only when the file's language mode is Markdown.

Does VS Code support GitHub Flavored Markdown?

Not fully. VS Code's documentation says the preview targets CommonMark using the markdown-it library. Tables and strikethrough work, and math and Mermaid are built in, but GitHub alerts, task-list checkboxes, footnotes, and emoji shortcodes need extensions.

Can VS Code render Mermaid diagrams without an extension?

Yes. Since VS Code 1.121 the built-in preview renders ```mermaid code blocks, with pan and zoom (hold Alt/Option and drag or scroll). The Markdown Preview Mermaid Support extension is only needed on older versions.

How do I export Markdown to PDF from VS Code?

VS Code has no built-in PDF export. Install an extension such as Markdown PDF (yzane.markdown-pdf) or Markdown Preview Enhanced, or open the file in a browser-based previewer and use its print-to-PDF option.

How do I make the preview look like GitHub?

Install Matt Bierner's "Markdown Preview Github Styling" extension, or the "GitHub Markdown Preview" pack that also adds emoji, task lists, and footnotes. It changes styling only — the parser is still VS Code's — so do a final check on GitHub for anything GitHub-specific.

Can I preview Markdown in VS Code without installing it?

Yes. vscode.dev runs VS Code in the browser with the same Markdown preview, and pressing "." on a GitHub repository opens it in github.dev. Our guide to previewing Markdown in a browser covers these and other no-install options.

Sources

Not at your own machine?
Open or paste a .md file in the browser — with Mermaid, math, and PDF export. More browser options.
Open Browser Previewer

More Markdown Tools & Guides

All tools are free, run in your browser, and require no account.

Live Markdown PreviewerTool

Edit Markdown with a real-time preview, Mermaid, KaTeX math, drag-and-drop files, and one-click export.

Open the tool
GitHub Markdown PreviewTool

Load any public README, test it, and look up any GitHub syntax in the complete cheat sheet.

Open the tool
Mermaid Live EditorTool

13 diagram types with examples, live rendering, and SVG/PNG download.

Open the tool
LaTeX Math PreviewTool

Typeset equations as you type, with a copy-ready KaTeX cheat sheet of 180+ commands.

Open the tool
README Template GeneratorTool

Pick sections, fill in your project, and download a GitHub-ready README.md with badges and a TOC.

Open the tool
AI Markdown ViewerTool

Paste ChatGPT, Claude, or Gemini output and read it formatted, with tables, code, and math.

Open the tool
What Is Markdown?Guide

A plain-English introduction: what Markdown and .md files are, where it came from, and where it is used.

Read the guide
Markdown in Google DocsGuide

Preview .md files in Drive, edit in Docs' Markdown mode, and paste, convert, or export Markdown.

Read the guide
Best Online Markdown ViewersGuide

Six free tools tested with the same document: rendering, privacy, and phone support compared.

Read the guide
GitHub Markdown Not Rendering?Guide

16 causes found by symptom — tables, lists, image paths, code fences, alerts, Mermaid, math — with tested fixes.

Read the guide
How to Open an .md FileGuide

Open and read Markdown files formatted on Windows, Mac, Linux, iPhone, Android, Word, and Google Docs.

Read the guide
Markdown Preview in Any EditorGuide

Exact preview shortcuts for Visual Studio, JetBrains, Zed, Xcode, Sublime, Neovim, Obsidian, and more.

Read the guide
Preview Markdown in a BrowserGuide

Six free ways to read .md files in Chrome, Edge, Firefox, or Safari — compared for privacy and features.

Read the guide