Repository navigation
Description
Background
Users would like the markdown preview to be opened when they open a markdown file. Feature requests #2766 and #54776 track a few different use cases, but the main one we are interested in right now is: when I open a markdown file, instead of opening the normal text editor, the markdown preview is opened instead.
This can now be implemented using custom editors: #77131
Current Status
The current insiders (1.41) contributes a custom editor for the markdown preview. It is not enabled by default by can be selected by running View: Reopen with with a markdown file open. You can also use the following setting to always open markdown files in preview mode instead of in the editor:
"workbench.editorAssociations": [
{
"viewType": "vscode.markdown.preview.editor",
"filenamePattern": "*.md"
}
]The custom editor should look identical to the existing markdown preview.
How to help
The markdown custom editor needs testing and polish before it can be shipped. We are looking for the community to drive this. I've created this issue to collect feedback and discussion of this work.
Before we ship this feature, we need to make sure that custom editor based previews work as existing VS Code users would expect and work with the existing markdown preview's behavior and settings. This issue is intentionally open ended. Try playing around with the custom editor based markdown preview and exploring what works as expected and what doesn't
Some starting areas to focus on:
- How do custom editor based previews Integrate with existing markdown previews?
- Switching editors.
- Scrolling.
- Links. (For example, where do links open?)
- Markdown security settings.
Activity
mjbvz commentedon Nov 13, 2019
Thanks. Can you please split individual problems to separate issue so we can track them better (link them back to this issue).
Also note that I am looking for the community to implement this, so please submit PRs with fixes if you want to see this stabilized.
sverg1 commentedon Nov 18, 2019
Matt Bierner (@mjbvz) @jcgerhard I am considering tackling the editor toggle; this will be my first dive into open-source and could use a quick pointer as to where I should be looking! I have the preview Markdown editor up and running on my fork, but where may I look in src? I can make and link an issue once I get my bearings.
mjbvz commentedon Nov 19, 2019
sverg1 This should likely not be a markdown specific command but a generic for custom editors. Something like:
toggle custom editorthat would switch between VS Code's standard text editor and the custom one (i.e. the markdown preview)Here's where the custom editor commands live:
vscode/src/vs/workbench/contrib/customEditor/browser/commands.ts
Line 60 in 27a33ee
The
ICustomEditorServiceandIEditorServiceshould have the functionality you need to implement this:Since this change would be going into core VS Code, it should not hardcode anything markdown specific
msindone commentedon Dec 8, 2019
Matt Bierner (@mjbvz) @jcgerhard Is help still wanted on the Outline View? This would also be my first dive into open source, so I was wondering if this would be a good task to work on and if I could have quick pointer as to where I should be looking in src? I have the preview Markdown editor up and running on my fork. Thanks!
thadras commentedon Feb 3, 2020
Usage notes of odd and errant behavior when double clicking within an
mdfilethat has been opened within a
previewviewport.Given that the
Markdownextension allows clicking links of othermdfiles to open the target file, such is done within the tab of the referrer. Whereas, one might suspect another tab would have been opened to preview the target file.Further, when double-clicking regular text within the file's
preview, rather than open a tab with aneditorview, the application throws an error:Also, the scroll position of the preview tab does not persist after changing away from, and then returning to the tab, as the above mentioned reference links to a known issue.
Otherwise, the
experimentalfeature works as expected.s1-en commentedon Nov 10, 2020
I want to report that Markdown files opened by default in the preview that have links that point to other Markdown files do not seem to load the other file. No matter how many times I click the link just wouldn't work.
However, if I double-click the preview (hence entering edit mode) and then open up the preview again from the icon in the top right, then the links work fine.
jasonwilliams commentedon Dec 8, 2020
Hey Matt Bierner (@mjbvz) i really like this, does this work on stable VSCode? I can see the
View: Reopen withoption that does work, but that config doesn't work in the settings.json.I agree with @jcgerhard there needs to be some variable bindings to switch back and forth between preview and code.
But apart from that, what's holding this up?
1 remaining item
jasonwilliams commentedon Dec 8, 2020
I agree, a lot of fixes here can be broken up.
Matt Bierner (@mjbvz) can I make an issue for toggling preview/editing mode with a keybinding? (in the background this would call
View: Reopen with). This sounds like it could be done in isolationjasonwilliams commentedon Dec 22, 2020
CMD + E is already assigned to "Find with selection" We would need another shortcut that lets you toggle between edit mode and preview. Suggestions welcome.
"ctrl + cmd + p" could work
jasonwilliams commentedon Dec 22, 2020
As per Matt Bierner (@mjbvz) advice I've created a scoped-down issue which just focuses on being able to toggle back and forth from the custom editor to the normal one.
#113298
Matt Bierner (@mjbvz) do you know how hard/easy it is to keep state so when opening a new document you're still using the custom editor of vice versa?
ssmooncoder commentedon Aug 6, 2021
Find widget
Cmd/Ctrl+Fdoesn't seem to work in preview.ssmooncoder commentedon Aug 10, 2021
vscode/extensions/markdown-language-features/src/features/previewManager.ts
Line 78 in 6533d46
Passing
webviewOptions: {enableFindWidget: true}as the third param seems to fix this problem.