How do you open multiple markdown previews at the same time in VS Code?
Asked Answered
S

2

13

In VSCode, as you can see here, opening a md file in preview mode will replace a current preview instead of adding another preview. You can only ever have one markdown preview open at a time.

How can I instead get the alternative behavior, where opening a md file in preview mode adds a brand new preview tab no matter what?

Sabbath answered 20/12, 2021 at 7:31 Comment(0)
S
21

While this isn't a perfect solution to the question, this is in my opinion a good workaround to this unwanted behavior.

  1. In VS Code, open a markdown file in the normal editor (not preview) mode.

  2. While currently on that markdown tab, open the Command Palette using your typical shortcut (on macOS the shortcut is cmd+shift+p).

  3. Now you need to search for the command 'Markdown: Open Locked Preview to the Side'. You can easily find it by typing 'locked'.

  4. So that you get rid of the side-by-side view, then drag that locked preview from the right side into your original left side. Now you have a locked preview that won't get replaced, ever. Do this for every markdown file you open. A little tedious but it works. Yay!

Another way to do this is to open a markdown file in preview mode. And then go to Command Palette & then search for and run 'Markdown: Toggle Preview Locking'.

Sabbath answered 20/12, 2021 at 7:31 Comment(3)
Thanks, this at least somewhat works though it's not easy to change the previews once locked.Markus
Excellent answer! TAEstival
Just learned about Locked Preview! Thanks for this.Exceptionable
G
2

Another workaround I like better is to have markdown files open as preview by default, which doesn't replace existing markdown preview windows. Add this to your config:

"workbench.editorAssociations": {
    "*.md": "vscode.markdown.preview.editor"
}

Markdown files you opened previously might continue to open as text (I think vscode remembers that as a preference). To open those files, use View: Reopen Editor With... command in the command palette and chose markdown preview.

Whenever you need to edit the markdown file, just double click anywhere in the markdown and it'll open in text edit mode

Guenna answered 14/5, 2024 at 20:25 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.