Setting `workbench.editorAssociations` to change the default open mode of markdown to preview doesn't work
Type: Bug
Step 1: Set settings.json.
"workbench.editorAssociations": {
"*.md": "vscode.markdown.preview.editor"
},
Step 2: Open any markdown file using vscode. I'm using the code --disable-extensions README.md command here.
Step 3: You can see that vscode doesn't open markdown as a preview.
VS Code version: Code 1.82.1 (6509174151d557a81c9d0b5f8a5a1e9274db5585, 2023-09-08T08:45:05.575Z) OS version: Windows_NT x64 10.0.19045 Modes:
System Info
| Item | Value |
|---|---|
| CPUs | AMD Ryzen 5 PRO 4650U with Radeon Graphics (12 x 2096) |
| GPU Status | 2d_canvas: enabled canvas_oop_rasterization: enabled_on direct_rendering_display_compositor: disabled_off_ok gpu_compositing: enabled multiple_raster_threads: enabled_on opengl: enabled_on rasterization: enabled raw_draw: disabled_off_ok video_decode: enabled video_encode: enabled vulkan: disabled_off webgl: enabled webgl2: enabled webgpu: enabled |
| Load (avg) | undefined |
| Memory (System) | 15.23GB (6.07GB free) |
| Process Argv | --disable-extensions README.md --crash-reporter-id f5996097-ae46-4ad3-8875-a294c592650a |
| Screen Reader | no |
| VM | 0% |
A/B Experiments
vsliv368:30146709
vsreu685:30147344
python383:30185418
vspor879:30202332
vspor708:30202333
vspor363:30204092
vslsvsres303:30308271
vserr242:30382549
pythontb:30283811
vsjup518:30340749
pythonptprofiler:30281270
vshan820:30294714
vstes263:30335439
vscod805cf:30301675
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
vsaa593:30376534
pythonvs932:30410667
py29gd2263:30792226
vsclangdc:30486549
c4g48928:30535728
dsvsc012:30540252
pynewext54:30695312
azure-dev_surveyone:30548225
vscccc:30803845
3biah626:30602489
f6dab269:30613381
a9j8j154:30646983
showlangstatbar:30737416
962ge761:30835153
pythonfmttext:30731395
fixshowwlkth:30771522
showindicator:30805244
pythongtdpath:30769146
i26e3531:30792625
pythonnosmt12:30797651
pythonidxptcf:30805731
pythonnoceb:30805159
dsvsc013:30795093
dsvsc014:30804076
diffeditorv2:30821572
dsvsc015:30829745
I had this problem as well and just apparently found a fix but unsure why. I noticed on your setting, there is a comma after the closing bracket indicating there are other settings below it.
Mine was this way as well, but I removed it and went through the editor associations settings in the UI to add the key and it added it to the bottom of my settings - and now it works for some reason. So the fix for me was just to move it to the bottom. The only setting that was below it for me was "redhat.telemetry.enabled": false so maybe that particular setting messed it up for me but that was my experience?
Either way, here is my fully functioning settings.json for reference:
{
"window.menuBarVisibility": "classic",
"workbench.colorTheme": "Monokai",
"workbench.startupEditor": "none",
"redhat.telemetry.enabled": false,
"workbench.editorAssociations": {
"*.md": "vscode.markdown.preview.editor"
}
}
I get this too, 1.100.2, mac. But it seems this issue isn't often complained about, so presumably it's some perfect storm of settings?
Interestingly, after forcing the .md's I was testing into preview with "reopen editor with...", subsequent opens worked. I tried a bunch of other .md files and they opened in the preview editor, but I consistently saw the ones I was testing fail to do so, even after dev reload window or full app restart.
I tried it on another machine, and couldn't get this to repro at all. Not sure what the cause is, but forcing some of the files to open with preview seemed to resolve it, if that helps any future people.