Markdown Auto Reopen
Open Markdown in your Markdown editor — even when another extension opens it as plain text.
The problem
VS Code lets you pick which editor opens a file type:
"workbench.editorAssociations": {
"*.md": "vscode.markdown.editor"
}
This works when you open the file — from the Explorer, Quick Open, a search result.
It does not work when an extension opens the file for you. Extensions that call
vscode.window.showTextDocument(uri) bypass editor associations entirely, and VS Code
always gives you the plain text editor. Chat/assistant extensions that link to files in
their output do exactly this, so every README.md link lands you in raw Markdown source
instead of the rendered editor you configured.
There is no setting that fixes this. This extension does.
What it does
When a Markdown file shows up in a plain text editor, it is reopened in the editor you
configured — once per open session, then it gets out of your way.
| What happens |
Result |
An extension opens notes.md as text |
Reopened in your Markdown editor |
| You switch to the source view (pencil icon / Open Source) |
Left alone — no fighting, no timeout |
| You close the tab and open the file again |
Reopened in the Markdown editor again |
| You opened it yourself in the Markdown editor, then switch to source |
Left alone |
The rule is simple: one conversion per open session. Once a file has been shown in the
Markdown editor, the extension stops touching it until every tab for that file is closed.
Requirements
Set the target editor association yourself, e.g. for the built-in Markdown editor:
"workbench.editorAssociations": { "*.md": "vscode.markdown.editor" }
The extension defaults to that same view type, so both paths — manual and extension-driven —
end up in the same editor.
Settings
| Setting |
Default |
Description |
mdAutoReopen.enabled |
true |
Master switch. |
mdAutoReopen.viewType |
vscode.markdown.editor |
Target editor view type. VS Code ships two: vscode.markdown.editor (the editable Markdown Editor) and vscode.markdown.preview.editor (the read-only Markdown Preview). Any custom editor that handles Markdown works. |
mdAutoReopen.excludeGlobs |
["**/node_modules/**"] |
Files to never touch. |
mdAutoReopen.closeGraceMs |
500 |
How long to wait after a tab closes before forgetting the file. Switching to the source view closes and reopens the tab, so a small grace period is needed to tell that apart from a real close. |
Commands
| Command |
Description |
Markdown Auto Reopen: Toggle Auto Reopen |
Toggle for the current window, without changing settings. |
Markdown Auto Reopen: Open Source |
Open the current file's source without it being converted back. |
What it deliberately does not touch
- Anything that is not a
file: URI — in-memory documents, diffs and untitled buffers.
Assistant extensions run their diff/approval flows on virtual file systems; converting
those would break them.
- Diff editors, notebooks and files already open in a custom editor.
- Files with unsaved changes.
Known limitation
If a link points at a specific line (notes.md:42), that line is lost on conversion — the
Markdown editor takes no line anchor. Disable the extension if you rely on line links more
than on rendered Markdown.
License
MIT