Repository navigation
Description
This issue arises from the parent issue: #84520
Description
I would like to quickly toggle between 2 markdown states:
- Source Code editor (This is the state you currently get by default)
- Custom Editor (the preview editor you see when opening preview mode if the file is markdown)
Toggling between modes should take place in the same current window. This way you'll get a smooth create-read-modify experience. For references have a look at typora.io or notable.md where this is perfectly implemented.
Persistent State
When toggling between 2 states i would like the states to be persistent.
What i mean by this, is if I toggle a document to preview mode, when I go to open another document, I'm still in preview mode until I toggle back. This is the behaviour of many other markdown viewers and is pretty standard at this point, if it can keep state across sessions that would be even better.
Steps to reproduce:
Add this to your settings:
"workbench.editorAssociations": [
{
"viewType": "vscode.markdown.preview.editor",
"filenamePattern": "*.md"
}
],Then open a markdown file, you can toggle state by calling "Reopen Editor with..." then selecting one of the 2 options. Opening a new file resets this choice.
Requested changes
As per the discussion in #84520 we would like to see a keyboard-shortcut which can toggle between these 2 states, and keep persistence.
Implementation detail
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:
const REOPEN_WITH_COMMAND_ID = 'reOpenWith'; The
ICustomEditorServiceandIEditorServiceshould have the functionality you need to implement this:
- Getting the currently active editor.
- Switching it to the custom editor or to the default text editor.
Since this change would be going into core VS Code, it should not hardcode anything markdown specific
Activity
vscodebot commentedon Dec 22, 2020
(Experimental duplicate detection)
Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:
olajohn-ajiboye commentedon Dec 27, 2020
Jason Williams (@jasonwilliams) Matt Bierner (@mjbvz) . I would like to tackle this if it's not been worked on yet.
jasonwilliams commentedon Dec 28, 2020
Ola John Ajiboye (@olajohn-ajiboye) no one is working on this so feel free!
olajohn-ajiboye commentedon Dec 28, 2020
Thanks Jason Williams (@jasonwilliams) , I will start working on this. Am I able to ask for pointers from you if I need additional clarifications or who else can help?
jasonwilliams commentedon Dec 28, 2020
Ola John Ajiboye (@olajohn-ajiboye) sure you can ask here.
Matt Bierner (@mjbvz) should hopefully be able to guide you too as he made the parent issue and created the custom editor
vscode-triage-bot commentedon Jan 16, 2021
This feature request is now a candidate for our backlog. The community has 60 days to upvote the issue. If it receives 20 upvotes we will move it to our backlog. If not, we will close it. To learn more about how we handle feature requests, please see our documentation.
Happy Coding!
mjbvz commentedon Jan 16, 2021
The existing
Toggle editor typecommand switches the type of the current editor so this feature request it to persist the choice too, correct? Maybe a newToggle default editor typecommand?To start, look at the
Toggle editor typecommand:vscode/src/vs/workbench/browser/parts/editor/editorActions.ts
Line 1934 in 64a1496
For the new command, you'll also want to save off the new setting. Here's an example of some code that does that:
vscode/src/vs/workbench/services/editor/common/editorOpenWith.ts
Line 140 in 6c4a00c
olajohn-ajiboye commentedon Jan 16, 2021
Thanks for the heads-up Matt Bierner (@mjbvz) , I will have another look at this.
olajohn-ajiboye commentedon Jan 21, 2021
Hey Jason Williams (@jasonwilliams) Matt Bierner (@mjbvz) , I am not able to reproduce the "Reopen Editor with..." option. I was able to see this option before, but it seems gone. Could this be due to an update?

jasonwilliams commentedon Jan 21, 2021
Ola John Ajiboye (@olajohn-ajiboye) what version of VSCode are you using? Are you using insiders or stable?
3 remaining items
jasonwilliams commentedon Mar 7, 2021
Ola John Ajiboye (@olajohn-ajiboye) maybe it’s only on insiders
vscode-triage-bot commentedon Mar 17, 2021
🙁 In the last 60 days, this feature request has received less than 20 community upvotes and we closed it. Still a big Thank You to you for taking the time to create this issue! To learn more about how we handle feature requests, please see our documentation.
Happy Coding!
jasonwilliams commentedon Mar 17, 2021
Can we reopen this? It’s being looked at
jasonwilliams commentedon Mar 17, 2021
Matt Bierner (@mjbvz) what's the purpose of
Toggle editor typeagain? Can that not be retrofitted with the purpose of changing from source-code to preview on markdowns (or cycling through custom editors) ?mjbvz commentedon Mar 19, 2021
Toggle editor typetoggles the type of the active editor. It's useful for quickly switching between a hex editor and a text editor for examplejasonwilliams commentedon Jul 26, 2022
Matt Bierner (@mjbvz) is this issue still valid?
mjbvz commentedon Dec 5, 2022
Thanks Jason Williams (@jasonwilliams). Yes I'll close this since I think this was addressed. Please open new issues if some part of this still isn't working as expected