Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I open a .md file in VS Code preview mode from terminal?

VS Code has a good preview mode for .md files. To open a file with this mode, I have to right-click the file in VS Code document tree, and click "Open Preview". One can also use shortcut Ctrl+Shift+V.

I would like to open a .md file in VS Code preview mode directly from Ubuntu's terminal.

I guess the command I'm looking for will be something like code README.md --preview ... but running code --help didn't help me to find my answer.

Is there any way I can do that?

like image 684
27636 Avatar asked Sep 02 '25 03:09

27636


1 Answers

Open VSCode settings.json file with;

  • Ctrl Shift P
  • Preferences: Open User Settings (JSON)

Add these lines to json file before the last }

    , // don't forget the comma
    "workbench.editorAssociations": {   
        "*.md": "vscode.markdown.preview.editor",
    }

Then whenever you want, you can use code README.md command.

like image 143
sglbl Avatar answered Sep 04 '25 22:09

sglbl