Search code examples
visual-studio-codecommand-line-interfacemarkdownpreview

How can I open a Markdown file in preview mode by default in VS Code?


I'm trying to configure a GitPod or GitHub Codespace so that the README.md gets automatically opened in preview mode at boot time.

I managed to open the file as:

code README.md

but that opens the editor, I'd like to open it in preview only mode.


Solution

  • If you google "github vscode issues markdown open preview by default", you will probably find this issue ticket pretty high up in the search results: Option to automatically open markdown in preview #54776. Quoting Matt Bernier from their comment there:

    To change this, you can configure the default editor for .md files (or whatever other markdown file extension you wish). Here's an example setting:

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

    Use the [View: Reopen Editor With...] command to switch back to the standard text editor.


    There's also another related issue ticket about opening the Markdown preview to the side by default: Automatically Activate Markdown Preview #2766. If you're interested in that one too, give it a thumbs up to show support, and subscribe to it to get notified of discussion and progress, but please avoid noisy comments like "+1" or "bump".