Coding

VS Code Markdown Preview: Open It, Side by Side, Settings

To open the VS Code Markdown preview, press Ctrl+Shift+V on Windows and Linux or Shift+Cmd+V on macOS. To see it next to the source, press Ctrl+K then V (Cmd+K then V on macOS).

No extension is needed. The preview is built into VS Code and works on any file with the Markdown language mode, such as .md files. This guide is based on the official documentation as of November 2026.

How to open the Markdown preview

GoalWindows / LinuxmacOSCommand name
Toggle between editor and preview in the same tabCtrl+Shift+VShift+Cmd+VMarkdown: Open Preview
Preview beside the editorCtrl+K VCmd+K VMarkdown: Open Preview to the Side

You can also right-click the editor tab of a Markdown file and select Open Preview. To run a command by name, open the Command Palette with Ctrl+Shift+P (Shift+Cmd+P on macOS) and type Markdown: Open Preview. If the shortcuts do nothing, check the Keyboard Shortcuts editor (File > Preferences > Keyboard Shortcuts) for a conflicting binding. Our Command Palette article covers running commands by name in more detail.

How the preview follows your edits

By default the preview follows the active Markdown file, so switching tabs changes what it shows. It updates as you type. A light gray bar in the left margin of the preview marks the line your cursor is on in the editor. Double-clicking an element in the preview opens the editor and scrolls to the nearest matching line.

Lock the preview to one file

Run Markdown: Toggle Preview Locking while the preview is the active tab. A locked preview stays on its file when you switch to another one, and its tab title starts with [Preview]. This helps when you want a README preview to stay open while you edit something else. Run the same command again to unlock.

Scroll sync between editor and preview

The editor and preview scroll together by default. Two settings control the directions separately:

  • markdown.preview.scrollPreviewWithEditor: whether scrolling the editor scrolls the preview.
  • markdown.preview.scrollEditorWithPreview: whether scrolling the preview scrolls the editor.

Changing either setting turns off synchronization in the matching direction. Set them in File > Preferences > Settings by searching for markdown.preview.scroll.

Why images or scripts don't show in the preview

The preview has a security setting. The default level is Strict, which blocks script execution and images loaded over http. When something is blocked, an alert appears in the top-right corner of the preview. Run Markdown: Change preview security settings to see the levels:

LevelScriptshttp content
Strict (default)BlockedBlocked
Allow insecure contentBlockedLoads
DisableAllowedLoads

The choice applies to all files in the workspace. For a missing image, changing the link from http:// to https:// is safer than lowering the level. Only use Disable on Markdown you wrote or trust, since it lets scripts in the document run.

Math, styling and outline

  • Math. The preview renders math with KaTeX: $a^2 + b^2 = c^2$ inline, or $$ ... $$ for a block. Set markdown.math.enabled to false to disable it.
  • Custom CSS. Add stylesheets with markdown.styles in your settings:
"markdown.styles": ["https://example.com/preview.css", "styles/preview.css"]

Entries can be https URLs or paths relative to the workspace. The second entry above is a made-up example path.

  • Outline. The Outline view at the bottom of the File Explorer shows the header hierarchy of the open Markdown file, which helps in long documents.

Extending the preview

The built-in preview supports the CommonMark specification. Extensions can add syntax by contributing a markdown-it plugin (markdown.markdownItPlugins in the extension's package.json), CSS (markdown.previewStyles) and scripts that run inside the preview (markdown.previewScripts). Such extensions activate the first time a Markdown preview is shown. If a feature such as diagrams or extra syntax is missing in your preview, it is not part of core VS Code, so look for an extension that contributes it.

If the preview doesn't work

  • Nothing happens on the shortcut. Confirm the file's language mode is Markdown (shown at the right of the status bar). Then run Markdown: Open Preview from the Command Palette to rule out a shortcut conflict.
  • Preview shows the wrong file. It is following the active file. Lock it with Markdown: Toggle Preview Locking.
  • Images or scripts missing. Look for the blocked-content alert in the preview's top-right corner and check the security level above.
  • Preview looks different from GitHub or your site. The preview uses its own styles. Add your stylesheet with markdown.styles, but expect small differences from other renderers.

Frequently asked questions

What is the shortcut for the VS Code Markdown preview?
Press Ctrl+Shift+V on Windows and Linux, or Shift+Cmd+V on macOS, to toggle between the editor and the preview in the same tab. To show the preview beside the editor, press Ctrl+K then V (Cmd+K then V on macOS), which runs Markdown: Open Preview to the Side.
Why are images missing from my Markdown preview?
By default the preview uses the Strict security level, which blocks images loaded over http. Switch the image URL to https, or run Markdown: Change preview security settings and pick Allow insecure content. The choice applies to every file in the workspace, so prefer fixing the URL.
Does the VS Code Markdown preview render math?
Yes. It renders math with KaTeX. Inline math goes between single dollar signs and math blocks between double dollar signs. To turn it off, set markdown.math.enabled to false.
Can I change how the preview looks?
Yes. Set markdown.styles to a list of stylesheet URLs. Each entry can be an https URL or a relative path to a CSS file in your workspace. Extensions can also contribute CSS to the preview.

Sources