首页 > 解决方案 > How to detect if an editor is a markdown preview?

问题描述

Command markdown.showSource shows the source code of a markdown preview, how to write the When condition so that markdown.showSource only triggers when the active editor is indeed a markdown preview?

标签: visual-studio-codemarkdownvscode-settingsvscode-keybinding

解决方案


"when": "markdownPreviewFocus"

How did I find this? (With a markdown preview editor open)

  1. Toggle the Help/Developer Tools On, go to its console.

  2. Start the command Developer: Inspect Context Keys

I just clicked anywhere in vscode. In the developer tools console, you will get a long list of active context keys. I searched for preview and there were a few but this one looked really promising and it worked!


推荐阅读