Skip to content

[Feature] - Toggle Custom Editor (Improved markdown support) #113298

Closed

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

#84520 (comment)

sverg1 This should likely not be a markdown specific command but a generic for custom editors. Something like: toggle custom editor that 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 ICustomEditorService and IEditorService should 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

  1. vscodebot commented on Dec 22, 2020

    @vscodebot

    (Experimental duplicate detection)
    Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:

  2. olajohn-ajiboye commented on Dec 27, 2020

    @olajohn-ajiboye

    Jason Williams (@jasonwilliams) Matt Bierner (@mjbvz) . I would like to tackle this if it's not been worked on yet.

  3. jasonwilliams commented on Dec 28, 2020

    @jasonwilliams
    ContributorAuthor

    Ola John Ajiboye (@olajohn-ajiboye) no one is working on this so feel free!

  4. olajohn-ajiboye commented on Dec 28, 2020

    @olajohn-ajiboye

    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?

  5. jasonwilliams commented on Dec 28, 2020

    @jasonwilliams
    ContributorAuthor

    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

  6. added
    markdown-ext
    feature-request
    on Jan 16, 2021
  7. vscode-triage-bot commented on Jan 16, 2021

    @vscode-triage-bot

    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!

  8. mjbvz commented on Jan 16, 2021

    @mjbvz
    Contributor

    The existing Toggle editor type command switches the type of the current editor so this feature request it to persist the choice too, correct? Maybe a newToggle default editor type command?

    To start, look at the Toggle editor type command:

    const activeEditorPane = this.editorService.activeEditorPane;

    For the new command, you'll also want to save off the new setting. Here's an example of some code that does that:

  9. added
    help wanted
    on Jan 16, 2021
  10. olajohn-ajiboye commented on Jan 16, 2021

    @olajohn-ajiboye

    Thanks for the heads-up Matt Bierner (@mjbvz) , I will have another look at this.

  11. olajohn-ajiboye commented on Jan 21, 2021

    @olajohn-ajiboye

    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?
    Screenshot 2021-01-21 at 12 23 13

  12. jasonwilliams commented on Jan 21, 2021

    @jasonwilliams
    ContributorAuthor

    Ola John Ajiboye (@olajohn-ajiboye) what version of VSCode are you using? Are you using insiders or stable?

  13. 3 remaining items

  14. jasonwilliams commented on Mar 7, 2021

    @jasonwilliams
    ContributorAuthor

    Ola John Ajiboye (@olajohn-ajiboye) maybe it’s only on insiders

  15. vscode-triage-bot commented on Mar 17, 2021

    @vscode-triage-bot

    🙁 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!

  16. jasonwilliams commented on Mar 17, 2021

    @jasonwilliams
    ContributorAuthor

    Can we reopen this? It’s being looked at

  17. jasonwilliams commented on Mar 17, 2021

    @jasonwilliams
    ContributorAuthor

    Matt Bierner (@mjbvz) what's the purpose of Toggle editor type again? Can that not be retrofitted with the purpose of changing from source-code to preview on markdowns (or cycling through custom editors) ?

  18. mjbvz commented on Mar 19, 2021

    @mjbvz
    Contributor

    Toggle editor type toggles the type of the active editor. It's useful for quickly switching between a hex editor and a text editor for example

  19. jasonwilliams commented on Jul 26, 2022

    @jasonwilliams
    ContributorAuthor

    Matt Bierner (@mjbvz) is this issue still valid?

  20. mjbvz commented on Dec 5, 2022

    @mjbvz
    Contributor

    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

  21. locked and limited conversation to collaborators on Jan 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

feature-requesthelp wantedmarkdown-ext

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions