# Markdown: markdownEditor.toggleMode only switches Preview → source; cannot return to Preview from plain text editor

**URL:** <https://forum.cursor.com/t/markdown-markdowneditor-togglemode-only-switches-preview-source-cannot-return-to-preview-from-plain-text-editor/160754>\
**Category:** Bug Reports\
**Tags:** keybindings\
**Created:** [May 15, 2026, 2:05pm UTC](https://forum.cursor.com/t/markdown-markdowneditor-togglemode-only-switches-preview-source-cannot-return-to-preview-from-plain-text-editor/160754 "2026-05-15T14:05:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Oleg\_Apostol](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/oleg_apostol/32/108712_2.png) [@Oleg\_Apostol](https://forum.cursor.com/u/Oleg_Apostol)\
**Post date:** [May 15, 2026, 2:05pm UTC](https://forum.cursor.com/t/markdown-markdowneditor-togglemode-only-switches-preview-source-cannot-return-to-preview-from-plain-text-editor/160754/1 "2026-05-15T14:05:51Z")

</div>

### Where does the bug appear (feature/product)?

Cursor IDE

### Describe the Bug

### Summary

`markdownEditor.toggleMode` (the in-tab **Preview / Markdown** toggle) only works when the active editor is Cursor’s Markdown editor (`workbench.editor.markdown`). After switching to **Markdown (raw)**, the implementation replaces that editor with the **default text editor**. The toggle command then has nothing to act on (`markdownEditorActive` is false; active pane is no longer the Markdown editor), so there is no way to bind a single shortcut that round-trips **source → Preview** the same way as **Preview → source**.

### Steps to reproduce

1. Open any `.md` file in Cursor’s Markdown editor (with **Preview / Markdown** pills).
2. Use **Markdown Editor: Toggle Editor Mode** (or a keybinding to `markdownEditor.toggleMode`) while **Preview** is selected → switches to **Markdown** / raw. ✓
3. With focus in the raw editor, run the same command again (or use the same keybinding with `when: markdownEditorActive` or without).

### Expected

The same action should switch back to **Preview** (rich mode), or at least the shortcut should remain valid for `.md` tabs.

### Actual

- With `"when": "markdownEditorActive"`, the shortcut **stops matching** after step 2 because `markdownEditorActive` becomes false.
- The command is effectively a no-op / unavailable from the plain text editor, even though it is still the same file.

### Notes / suspected cause (for your team)

`switchEditorMode` appears to use `editorService.replaceEditors` with `options.override` set to the default text editor id for **RAW** and `workbench.editor.markdown` for **RICH**. `markdownEditor.toggleMode` only handles the case `activeEditorPane instanceof` the Markdown editor pane + `MarkdownEditorInput`. Once the tab is a normal text editor, that branch never runs, so there is no symmetric path back to rich preview without **Reopen Editor With…**.

### Environment

- OS: macOS (darwin 25.x)
- Cursor: [paste **About Cursor** version + VS Code base version]

### Workaround

**Reopen Editor With…** and choose Cursor’s **Markdown** editor again; then Preview/Markdown toggle works for Preview → source only until the next time raw mode replaces the editor.

### Steps to Reproduce

have a keybinding, for eaxmple:  
{  
“key”: “alt+cmd+p”,  
“command”: “markdownEditor.toggleMode”,  
“when”: “markdownEditorActive”  
},

and try to toggle markdown preview

### Expected Behavior

when in the editor view of markdown file (e.g. README.md) and hotkey pressed - it should switch to preview (same as click on small “Preview” button on top-right corner)

### Operating System

MacOS

### Version Information

Version: 3.4.17 (Universal)  
VSCode Version: 1.105.1  
Commit: 93e603f703cd553a6bb3644711a3379bbbb31180  
Date: 2026-05-13T21:39:55.724Z (1 day ago)  
Layout: editor  
Build Type: Stable  
Release Track: Default  
Electron: 39.8.1  
Chromium: 142.0.7444.265  
Node.js: 22.22.1  
V8: 14.2.231.22-electron.0  
OS: Darwin arm64 25.3.0

### Does this stop you from using Cursor

No - Cursor works, but with this issue

---

<div class="post-metadata">

**Author:** ![mohitjain](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/mohitjain/32/100229_2.png) [@mohitjain](https://forum.cursor.com/u/mohitjain)\
**Post date:** [May 18, 2026, 8:24am UTC](https://forum.cursor.com/t/markdown-markdowneditor-togglemode-only-switches-preview-source-cannot-return-to-preview-from-plain-text-editor/160754/8 "2026-05-18T08:24:11Z")

</div>

This is a confirmed bug. Thanks for flagging it.

In the meantime, two workarounds:

1. Click the Preview/Markdown pills in the top-right corner (these still work because they bypass the command precondition)

2. Add a complementary keybinding for the return trip:

`{`  
`"key": "alt+cmd+p",`  
`"command": "workbench.action.reopenWithEditor",`  
`"args": { "editorId": "workbench.editor.markdown" },`  
`"when": "resourceLangId == markdown && !markdownEditorActive"`  
`}`

This fires when you’re in a raw `.md` file, complementing your existing binding.

---

<div class="post-metadata">

**Author:** ![Raymond\_Wang](https://avatars.discourse-cdn.com/v4/letter/r/b38774/32.png) [@Raymond\_Wang](https://forum.cursor.com/u/Raymond_Wang)\
**Post date:** [July 12, 2026, 9:17pm UTC](https://forum.cursor.com/t/markdown-markdowneditor-togglemode-only-switches-preview-source-cannot-return-to-preview-from-plain-text-editor/160754/10 "2026-07-12T21:17:46Z")

</div>

Any update on this? Would appreciate this fix a lot.

---

<div class="post-metadata">

**Author:** ![Oleg\_Apostol](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/oleg_apostol/32/108712_2.png) [@Oleg\_Apostol](https://forum.cursor.com/u/Oleg_Apostol)\
**Post date:** [July 14, 2026, 8:48am UTC](https://forum.cursor.com/t/markdown-markdowneditor-togglemode-only-switches-preview-source-cannot-return-to-preview-from-plain-text-editor/160754/11 "2026-07-14T08:48:31Z")

</div>

> [@mohitjain](#):
>
> 1. Add a complementary keybinding for the return trip:
> 
> `{`  
> `"key": "alt+cmd+p",`  
> `"command": "workbench.action.reopenWithEditor",`  
> `"args": { "editorId": "workbench.editor.markdown" },`  
> `"when": "resourceLangId == markdown && !markdownEditorActive"`  
> `}`

This is a lot of **extra steps** , because its just opens dropdown, then you have to choose and option with arrow keys and confirm with Enter.
